Work around race condition in SCR runtime when bundle pointer is null
Change-Id: Ib380730af66f66a0a628f768b45ff2eb6237aa05
diff --git a/cli/src/main/java/org/onosproject/cli/ScrListCommand.java b/cli/src/main/java/org/onosproject/cli/ScrListCommand.java
index 2de0c8e..113b271 100644
--- a/cli/src/main/java/org/onosproject/cli/ScrListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/ScrListCommand.java
@@ -38,25 +38,32 @@
scrService.getComponentDescriptionDTOs()
.forEach(componentDto -> {
- scrService.getComponentConfigurationDTOs(componentDto)
- .forEach(configurationDto -> {
- String state;
- switch (configurationDto.state) {
- case ComponentConfigurationDTO.ACTIVE: {
- state = "ACTIVE";
- break;
+ try {
+ scrService.getComponentConfigurationDTOs(componentDto)
+ .forEach(configurationDto -> {
+ String state;
+ switch (configurationDto.state) {
+ case ComponentConfigurationDTO.ACTIVE: {
+ state = "ACTIVE";
+ break;
+ }
+ case ComponentConfigurationDTO.SATISFIED: {
+ state = "SATISFIED";
+ break;
+ }
+ default: {
+ state = "UNKNOWN";
+ }
}
- case ComponentConfigurationDTO.SATISFIED: {
- state = "SATISFIED";
- break;
- }
- default: {
- state = "UNKNOWN";
- }
- }
- formatter.format("%3d | %9s | %s\n", configurationDto.id, state, componentDto.name);
- });
- });
+ formatter.format("%3d | %9s | %s\n", configurationDto.id, state, componentDto.name);
+ });
+ } catch (NullPointerException npe) {
+ // Work around for a race condition inside of the SCR runtime.
+ // In certain conditions, the SCR code gets an NPE due to a
+ // null bundle pointer
+ // Nothing we can do with the data, skip this entry
+ }
+ });
print(output.toString());
}