Prevent NPE in obr:info command if resource is not complete
@@ -59,8 +59,8 @@ public class InfoCommand extends ObrCommandSupport {
}
}
- private void printResource(PrintStream out, Resource resource)
- {
+ private void printResource(PrintStream out, Resource resource) {
+ if (out != null && resource != null) {
// OBR R5 per Spec has no presentation name
String resourceId = getResourceId(resource);
@@ -82,8 +82,7 @@ public class InfoCommand extends ObrCommandSupport {
}
Requirement[] reqs = resource.getRequirements();
- if ((reqs != null) && (reqs.length > 0))
- {
+ if ((reqs != null) && (reqs.length > 0)) {
out.println("Requires:");
for (Requirement req : reqs) {
out.println(" " + req.getName() + ":" + req.getFilter());
@@ -91,13 +90,13 @@ public class InfoCommand extends ObrCommandSupport {
}
Capability[] caps = resource.getCapabilities();
- if ((caps != null) && (caps.length > 0))
- {
+ if ((caps != null) && (caps.length > 0)) {
out.println("Capabilities:");
for (Capability cap : caps) {
out.println(" " + cap.getName() + ":" + cap.getPropertiesAsMap());
}
}
}
+ }
}
