mirror of
https://github.com/apache/nifi.git
synced 2025-02-07 18:48:51 +00:00
NIFI-5609: Fixed NullPointer when attempting to view status history for a component that has not yet run
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #3012
This commit is contained in:
parent
f570cb980d
commit
3dd548e807
@ -27,6 +27,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
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) {
|
private synchronized StatusHistory getStatusHistory(final String componentId, final boolean includeCounters, final Set<MetricDescriptor<?>> defaultMetricDescriptors) {
|
||||||
final ComponentStatusHistory history = componentStatusHistories.get(componentId);
|
final ComponentStatusHistory history = componentStatusHistories.get(componentId);
|
||||||
if (history == null) {
|
if (history == null) {
|
||||||
return null;
|
return createEmptyStatusHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Date> dates = timestamps.asList();
|
final List<Date> dates = timestamps.asList();
|
||||||
return history.toStatusHistory(dates, includeCounters, defaultMetricDescriptors);
|
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
|
@Override
|
||||||
public GarbageCollectionHistory getGarbageCollectionHistory(final Date start, final Date end) {
|
public GarbageCollectionHistory getGarbageCollectionHistory(final Date start, final Date end) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user