From 2fb1409e4adf094fd9e6d400bbe2ac6dbed90c6a Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 14 Dec 2018 12:27:51 -0500 Subject: [PATCH] Fix DataSourceAnalysisEvent.getDataSource NPEs --- .../autopsy/ingest/events/DataSourceAnalysisEvent.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java index fb7d2f2f56..94f628a601 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java @@ -39,6 +39,7 @@ public abstract class DataSourceAnalysisEvent extends AutopsyEvent implements Se private final long ingestJobId; private final long dataSourceIngestJobId; private transient Content dataSource; + private final long dataSourceObjectId; /** * Constructs an instance of the base class for events published in @@ -56,6 +57,7 @@ public abstract class DataSourceAnalysisEvent extends AutopsyEvent implements Se this.ingestJobId = ingestJobId; this.dataSourceIngestJobId = dataSourceIngestJobId; this.dataSource = dataSource; + this.dataSourceObjectId = dataSource.getId(); } /** @@ -81,7 +83,8 @@ public abstract class DataSourceAnalysisEvent extends AutopsyEvent implements Se /** * Gets the data source associated with this event. * - * @return The data source. + * @return The data source or null if there is an error getting the data + * source from an event published by a remote node. */ public Content getDataSource() { /** @@ -96,11 +99,10 @@ public abstract class DataSourceAnalysisEvent extends AutopsyEvent implements Se return dataSource; } try { - long id = (Long) super.getNewValue(); - dataSource = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(id); + dataSource = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(dataSourceObjectId); return dataSource; } catch (NoCurrentCaseException | TskCoreException ex) { - logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS + logger.log(Level.SEVERE, String.format("Error doing lazy load of data source (objId=%d) for remote event", this.dataSourceObjectId), ex); //NON-NLS return null; } }