bug fixes

This commit is contained in:
Greg DiCristofaro 2022-01-25 10:27:09 -05:00
parent 23eb75b12b
commit 7a7a48762f
2 changed files with 20 additions and 7 deletions

View File

@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -84,8 +85,9 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
private Blackboard blackboard;
private CommunicationArtifactsHelper communicationArtifactsHelper;
// A cache of custom attributes for the VcardParser unique to each ingest run.
private Map<String, BlackboardAttribute.Type> customAttributeCache;
// A cache of custom attributes for the VcardParser unique to each ingest run, but consistent across threads.
private static ConcurrentMap<String, BlackboardAttribute.Type> customAttributeCache = new ConcurrentHashMap<>();
private static Object customAttributeCacheLock = new Object();
private static final int MBOX_SIZE_TO_SPLIT = 1048576000;
private Case currentCase;
@ -100,7 +102,13 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
@Messages({"ThunderbirdMboxFileIngestModule.noOpenCase.errMsg=Exception while getting open case."})
public void startUp(IngestJobContext context) throws IngestModuleException {
this.context = context;
this.customAttributeCache = new ConcurrentHashMap<>();
synchronized(customAttributeCacheLock) {
if (!customAttributeCache.isEmpty()) {
customAttributeCache.clear();
}
}
try {
currentCase = Case.getCurrentCaseThrows();
fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
@ -917,7 +925,11 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
@Override
public void shutDown() {
// nothing to shut down
synchronized(customAttributeCacheLock) {
if (!customAttributeCache.isEmpty()) {
customAttributeCache.clear();
}
}
}
}

View File

@ -40,6 +40,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import org.apache.commons.lang3.StringUtils;
import org.openide.util.NbBundle;
@ -102,12 +103,12 @@ final class VcardParser {
* A custom attribute cache provided to every VcardParser from the
* ThunderbirdMboxFileIngestModule, but unique to one ingest run.
*/
private final Map<String, BlackboardAttribute.Type> customAttributeCache;
private final ConcurrentMap<String, BlackboardAttribute.Type> customAttributeCache;
/**
* Create a VcardParser object.
*/
VcardParser(Case currentCase, IngestJobContext context, Map<String, BlackboardAttribute.Type> customAttributeCache) {
VcardParser(Case currentCase, IngestJobContext context, ConcurrentMap<String, BlackboardAttribute.Type> customAttributeCache) {
this.context = context;
this.currentCase = currentCase;
tskCase = currentCase.getSleuthkitCase();