You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2018/09/19 20:57:36 UTC

nifi git commit: NIFI-5609: Fixed NullPointer when attempting to view status history for a component that has not yet run

Repository: nifi
Updated Branches:
  refs/heads/master f570cb980 -> 3dd548e80


NIFI-5609: Fixed NullPointer when attempting to view status history for a component that has not yet run

Signed-off-by: Matthew Burgess <ma...@apache.org>

This closes #3012


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/3dd548e8
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/3dd548e8
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/3dd548e8

Branch: refs/heads/master
Commit: 3dd548e807c80749a99f83e18857cab879cd9c21
Parents: f570cb9
Author: Mark Payne <ma...@hotmail.com>
Authored: Wed Sep 19 16:17:29 2018 -0400
Committer: Matthew Burgess <ma...@apache.org>
Committed: Wed Sep 19 16:56:42 2018 -0400

----------------------------------------------------------------------
 .../VolatileComponentStatusRepository.java      | 24 +++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/3dd548e8/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepository.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepository.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepository.java
index 5336d17..b280214 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepository.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepository.java
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -166,13 +167,34 @@ public class VolatileComponentStatusRepository implements ComponentStatusReposit
     private synchronized StatusHistory getStatusHistory(final String componentId, final boolean includeCounters, final Set<MetricDescriptor<?>> defaultMetricDescriptors) {
         final ComponentStatusHistory history = componentStatusHistories.get(componentId);
         if (history == null) {
-            return null;
+            return createEmptyStatusHistory();
         }
 
         final List<Date> dates = timestamps.asList();
         return history.toStatusHistory(dates, includeCounters, defaultMetricDescriptors);
     }
 
+    private StatusHistory createEmptyStatusHistory() {
+        final Date dateGenerated = new Date();
+
+        return new StatusHistory() {
+            @Override
+            public Date getDateGenerated() {
+                return dateGenerated;
+            }
+
+            @Override
+            public Map<String, String> getComponentDetails() {
+                return Collections.emptyMap();
+            }
+
+            @Override
+            public List<StatusSnapshot> getStatusSnapshots() {
+                return Collections.emptyList();
+            }
+        };
+    }
+
 
     @Override
     public GarbageCollectionHistory getGarbageCollectionHistory(final Date start, final Date end) {