Handle invalid bundle case properly properly in "requirers" and "exports"
commnands. (FELIX-1019)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@767853 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/ExportsCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/ExportsCommandImpl.java
index 8db20eb..9637c6e 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/ExportsCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/ExportsCommandImpl.java
@@ -78,13 +78,20 @@
{
long l = Long.parseLong(id);
Bundle bundle = m_context.getBundle(l);
- ExportedPackage[] exports = pa.getExportedPackages(bundle);
- if (separatorNeeded)
+ if (bundle != null)
{
- out.println("");
+ ExportedPackage[] exports = pa.getExportedPackages(bundle);
+ if (separatorNeeded)
+ {
+ out.println("");
+ }
+ printExports(out, bundle, exports);
+ separatorNeeded = true;
}
- printExports(out, bundle, exports);
- separatorNeeded = true;
+ else
+ {
+ err.println("Bundle ID " + id + " is invalid.");
+ }
}
catch (NumberFormatException ex)
{
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/RequirersCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/RequirersCommandImpl.java
index 42107ff..d21a404 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/RequirersCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/RequirersCommandImpl.java
@@ -78,19 +78,26 @@
{
long l = Long.parseLong(id);
Bundle bundle = m_context.getBundle(l);
- RequiredBundle[] rbs = pa.getRequiredBundles(bundle.getSymbolicName());
- for (int i = 0; (rbs != null) && (i < rbs.length); i++)
+ if (bundle != null)
{
- if (rbs[i].getBundle() == bundle)
+ RequiredBundle[] rbs = pa.getRequiredBundles(bundle.getSymbolicName());
+ for (int i = 0; (rbs != null) && (i < rbs.length); i++)
{
- if (separatorNeeded)
+ if (rbs[i].getBundle() == bundle)
{
- out.println("");
+ if (separatorNeeded)
+ {
+ out.println("");
+ }
+ printRequiredBundles(out, bundle, rbs[i].getRequiringBundles());
+ separatorNeeded = true;
}
- printRequiredBundles(out, bundle, rbs[i].getRequiringBundles());
- separatorNeeded = true;
}
}
+ else
+ {
+ err.println("Bundle ID " + id + " is invalid.");
+ }
}
catch (NumberFormatException ex)
{