mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 17:57:43 +00:00
Merge pull request #2259 from eugene7646/concurrent_mod_1839
1839 Fixed ConcurrentModificationException in several Autopsy datamodel objects
This commit is contained in:
commit
5cb6afb67a
@ -72,6 +72,7 @@ public class EmailExtracted implements AutopsyVisitableItem {
|
|||||||
|
|
||||||
private final class EmailResults extends Observable {
|
private final class EmailResults extends Observable {
|
||||||
|
|
||||||
|
// NOTE: the map can be accessed by multiple worker threads and needs to be synchronized
|
||||||
private final Map<String, Map<String, List<Long>>> accounts = new LinkedHashMap<>();
|
private final Map<String, Map<String, List<Long>>> accounts = new LinkedHashMap<>();
|
||||||
|
|
||||||
EmailResults() {
|
EmailResults() {
|
||||||
@ -79,20 +80,28 @@ public class EmailExtracted implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getAccounts() {
|
public Set<String> getAccounts() {
|
||||||
|
synchronized (accounts) {
|
||||||
return accounts.keySet();
|
return accounts.keySet();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> getFolders(String account) {
|
public Set<String> getFolders(String account) {
|
||||||
|
synchronized (accounts) {
|
||||||
return accounts.get(account).keySet();
|
return accounts.get(account).keySet();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Long> getArtifactIds(String account, String folder) {
|
public List<Long> getArtifactIds(String account, String folder) {
|
||||||
|
synchronized (accounts) {
|
||||||
return accounts.get(account).get(folder);
|
return accounts.get(account).get(folder);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void update() {
|
public void update() {
|
||||||
|
synchronized (accounts) {
|
||||||
accounts.clear();
|
accounts.clear();
|
||||||
|
}
|
||||||
if (skCase == null) {
|
if (skCase == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -107,6 +116,7 @@ public class EmailExtracted implements AutopsyVisitableItem {
|
|||||||
|
|
||||||
try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
||||||
ResultSet resultSet = dbQuery.getResultSet();
|
ResultSet resultSet = dbQuery.getResultSet();
|
||||||
|
synchronized (accounts) {
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
final String path = resultSet.getString("value_text"); //NON-NLS
|
final String path = resultSet.getString("value_text"); //NON-NLS
|
||||||
final long artifactId = resultSet.getLong("artifact_id"); //NON-NLS
|
final long artifactId = resultSet.getLong("artifact_id"); //NON-NLS
|
||||||
@ -126,6 +136,7 @@ public class EmailExtracted implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
messages.add(artifactId);
|
messages.add(artifactId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (TskCoreException | SQLException ex) {
|
} catch (TskCoreException | SQLException ex) {
|
||||||
logger.log(Level.WARNING, "Cannot initialize email extraction: ", ex); //NON-NLS
|
logger.log(Level.WARNING, "Cannot initialize email extraction: ", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class HashsetHits implements AutopsyVisitableItem {
|
|||||||
private class HashsetResults extends Observable {
|
private class HashsetResults extends Observable {
|
||||||
|
|
||||||
// maps hashset name to list of artifacts for that set
|
// maps hashset name to list of artifacts for that set
|
||||||
|
// NOTE: the map can be accessed by multiple worker threads and needs to be synchronized
|
||||||
private final Map<String, Set<Long>> hashSetHitsMap = new LinkedHashMap<>();
|
private final Map<String, Set<Long>> hashSetHitsMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
HashsetResults() {
|
HashsetResults() {
|
||||||
@ -86,18 +86,25 @@ public class HashsetHits implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> getSetNames() {
|
List<String> getSetNames() {
|
||||||
List<String> names = new ArrayList<>(hashSetHitsMap.keySet());
|
List<String> names;
|
||||||
|
synchronized (hashSetHitsMap) {
|
||||||
|
names = new ArrayList<>(hashSetHitsMap.keySet());
|
||||||
|
}
|
||||||
Collections.sort(names);
|
Collections.sort(names);
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Long> getArtifactIds(String hashSetName) {
|
Set<Long> getArtifactIds(String hashSetName) {
|
||||||
|
synchronized (hashSetHitsMap) {
|
||||||
return hashSetHitsMap.get(hashSetName);
|
return hashSetHitsMap.get(hashSetName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
final void update() {
|
final void update() {
|
||||||
|
synchronized (hashSetHitsMap) {
|
||||||
hashSetHitsMap.clear();
|
hashSetHitsMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (skCase == null) {
|
if (skCase == null) {
|
||||||
return;
|
return;
|
||||||
@ -113,6 +120,7 @@ public class HashsetHits implements AutopsyVisitableItem {
|
|||||||
|
|
||||||
try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
||||||
ResultSet resultSet = dbQuery.getResultSet();
|
ResultSet resultSet = dbQuery.getResultSet();
|
||||||
|
synchronized (hashSetHitsMap) {
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
String setName = resultSet.getString("value_text"); //NON-NLS
|
String setName = resultSet.getString("value_text"); //NON-NLS
|
||||||
long artifactId = resultSet.getLong("artifact_id"); //NON-NLS
|
long artifactId = resultSet.getLong("artifact_id"); //NON-NLS
|
||||||
@ -121,6 +129,7 @@ public class HashsetHits implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
hashSetHitsMap.get(setName).add(artifactId);
|
hashSetHitsMap.get(setName).add(artifactId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (TskCoreException | SQLException ex) {
|
} catch (TskCoreException | SQLException ex) {
|
||||||
logger.log(Level.WARNING, "SQL Exception occurred: ", ex); //NON-NLS
|
logger.log(Level.WARNING, "SQL Exception occurred: ", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
@ -64,20 +64,28 @@ public class InterestingHits implements AutopsyVisitableItem {
|
|||||||
|
|
||||||
private class InterestingResults extends Observable {
|
private class InterestingResults extends Observable {
|
||||||
|
|
||||||
|
// NOTE: the map can be accessed by multiple worker threads and needs to be synchronized
|
||||||
private final Map<String, Set<Long>> interestingItemsMap = new LinkedHashMap<>();
|
private final Map<String, Set<Long>> interestingItemsMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
public List<String> getSetNames() {
|
public List<String> getSetNames() {
|
||||||
List<String> setNames = new ArrayList<>(interestingItemsMap.keySet());
|
List<String> setNames;
|
||||||
|
synchronized (interestingItemsMap) {
|
||||||
|
setNames = new ArrayList<>(interestingItemsMap.keySet());
|
||||||
|
}
|
||||||
Collections.sort(setNames);
|
Collections.sort(setNames);
|
||||||
return setNames;
|
return setNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Long> getArtifactIds(String setName) {
|
public Set<Long> getArtifactIds(String setName) {
|
||||||
|
synchronized (interestingItemsMap) {
|
||||||
return interestingItemsMap.get(setName);
|
return interestingItemsMap.get(setName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
synchronized (interestingItemsMap) {
|
||||||
interestingItemsMap.clear();
|
interestingItemsMap.clear();
|
||||||
|
}
|
||||||
loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
|
loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
|
||||||
loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
|
loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
|
||||||
setChanged();
|
setChanged();
|
||||||
@ -103,6 +111,7 @@ public class InterestingHits implements AutopsyVisitableItem {
|
|||||||
+ " AND blackboard_artifacts.artifact_type_id=" + artId; //NON-NLS
|
+ " AND blackboard_artifacts.artifact_type_id=" + artId; //NON-NLS
|
||||||
|
|
||||||
try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
||||||
|
synchronized (interestingItemsMap) {
|
||||||
ResultSet resultSet = dbQuery.getResultSet();
|
ResultSet resultSet = dbQuery.getResultSet();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
String value = resultSet.getString("value_text"); //NON-NLS
|
String value = resultSet.getString("value_text"); //NON-NLS
|
||||||
@ -112,6 +121,7 @@ public class InterestingHits implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
interestingItemsMap.get(value).add(artifactId);
|
interestingItemsMap.get(value).add(artifactId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (TskCoreException | SQLException ex) {
|
} catch (TskCoreException | SQLException ex) {
|
||||||
logger.log(Level.WARNING, "SQL Exception occurred: ", ex); //NON-NLS
|
logger.log(Level.WARNING, "SQL Exception occurred: ", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
@ -73,33 +73,41 @@ public class KeywordHits implements AutopsyVisitableItem {
|
|||||||
private final class KeywordResults extends Observable {
|
private final class KeywordResults extends Observable {
|
||||||
|
|
||||||
// Map from listName/Type to Map of keyword to set of artifact Ids
|
// Map from listName/Type to Map of keyword to set of artifact Ids
|
||||||
private final Map<String, Map<String, Set<Long>>> topLevelMap;
|
// NOTE: the map can be accessed by multiple worker threads and needs to be synchronized
|
||||||
|
private final Map<String, Map<String, Set<Long>>> topLevelMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
KeywordResults() {
|
KeywordResults() {
|
||||||
topLevelMap = new LinkedHashMap<>();
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> getListNames() {
|
List<String> getListNames() {
|
||||||
|
synchronized (topLevelMap) {
|
||||||
List<String> names = new ArrayList<>(topLevelMap.keySet());
|
List<String> names = new ArrayList<>(topLevelMap.keySet());
|
||||||
// this causes the "Single ..." terms to be in the middle of the results,
|
// this causes the "Single ..." terms to be in the middle of the results,
|
||||||
// which is wierd. Make a custom comparator or do something else to maek them on top
|
// which is wierd. Make a custom comparator or do something else to maek them on top
|
||||||
//Collections.sort(names);
|
//Collections.sort(names);
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<String> getKeywords(String listName) {
|
List<String> getKeywords(String listName) {
|
||||||
List<String> keywords = new ArrayList<>(topLevelMap.get(listName).keySet());
|
List<String> keywords;
|
||||||
|
synchronized (topLevelMap) {
|
||||||
|
keywords = new ArrayList<>(topLevelMap.get(listName).keySet());
|
||||||
|
}
|
||||||
Collections.sort(keywords);
|
Collections.sort(keywords);
|
||||||
return keywords;
|
return keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Long> getArtifactIds(String listName, String keyword) {
|
Set<Long> getArtifactIds(String listName, String keyword) {
|
||||||
|
synchronized (topLevelMap) {
|
||||||
return topLevelMap.get(listName).get(keyword);
|
return topLevelMap.get(listName).get(keyword);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// populate maps based on artifactIds
|
// populate maps based on artifactIds
|
||||||
void populateMaps(Map<Long, Map<Long, String>> artifactIds) {
|
void populateMaps(Map<Long, Map<Long, String>> artifactIds) {
|
||||||
|
synchronized (topLevelMap) {
|
||||||
topLevelMap.clear();
|
topLevelMap.clear();
|
||||||
|
|
||||||
// map of list name to keword to artifact IDs
|
// map of list name to keword to artifact IDs
|
||||||
@ -151,6 +159,7 @@ public class KeywordHits implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
topLevelMap.putAll(listsMap);
|
topLevelMap.putAll(listsMap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user