Fix NPE bug and lack of output for unmatched search. (FELIX-2937, FELIX-2938)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1097224 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java b/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java
index 34a137c..a8231ed 100644
--- a/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java
+++ b/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java
@@ -272,7 +272,7 @@
targetVersion = args[argIdx].substring(idx + 1);
}
Resource[] resources = searchRepository(ra, targetName, targetVersion);
- if (resources == null)
+ if ((resources == null) || (resources.length == 0))
{
System.err.println("Unknown bundle and/or version: " + args[argIdx]);
}
@@ -507,13 +507,21 @@
try
{
Bundle bundle = m_bc.getBundle(Long.parseLong(targetId));
- targetId = bundle.getSymbolicName();
+ if (bundle != null)
+ {
+ targetId = bundle.getSymbolicName();
+ }
+ else
+ {
+ return null;
+ }
}
catch (NumberFormatException ex)
{
// It was not a number, so ignore.
}
+
// The targetId may be a bundle name or a bundle symbolic name,
// so create the appropriate LDAP query.
StringBuffer sb = new StringBuffer("(|(presentationname=");