Author: thomas.diesler(a)jboss.com
Date: 2010-02-05 07:47:00 -0500 (Fri, 05 Feb 2010)
New Revision: 100478
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
Log:
Prevent NPE on RemoteBundle.getState()
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
---
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-02-05
12:46:56 UTC (rev 100477)
+++
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-02-05
12:47:00 UTC (rev 100478)
@@ -196,11 +196,11 @@
}
/**
- * Delegates to {@link OSGiTestHelper#getFramework()}
+ * Delegates to {@link OSGiTestHelper#getFrameworkName()}
*/
- public String getFramework()
+ public String getFrameworkName()
{
- return getTestHelper().getFramework();
+ return getTestHelper().getFrameworkName();
}
public VirtualFile assembleBundle(String name, String resource, Class<?>...
packages) throws Exception
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
---
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-02-05
12:46:56 UTC (rev 100477)
+++
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-02-05
12:47:00 UTC (rev 100478)
@@ -204,7 +204,7 @@
return targetContainer;
}
- public String getFramework()
+ public String getFrameworkName()
{
String framework = System.getProperty("framework");
if (framework == null || framework.length() == 0 ||
framework.equals("${framework}"))
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
---
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-05
12:46:56 UTC (rev 100477)
+++
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-05
12:47:00 UTC (rev 100478)
@@ -32,7 +32,6 @@
import java.util.Dictionary;
import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import org.jboss.osgi.spi.management.ManagedBundle;
@@ -87,7 +86,7 @@
symbolicName = bundle.getSymbolicName();
objectName = bundle.getObjectName();
location = bundle.getLocation();
-
+
defaultHeaders = bundle.getHeaders(null);
rawHeaders = bundle.getHeaders("");
@@ -100,25 +99,17 @@
{
if (uninstalled == true)
return Bundle.UNINSTALLED;
-
+
try
{
- MBeanServerConnection server = getRuntime().getMBeanServer();
- if (server.isRegistered(objectName))
- {
- return bundle.getState();
- }
+ return bundle.getState();
}
catch (RuntimeException rte)
{
- Throwable cause = rte.getCause() != null ? rte.getCause() : null;
+ Throwable cause = rte.getCause() != null ? rte.getCause() : rte;
if (cause instanceof InstanceNotFoundException == false)
log.warn("Cannot get state for: " + objectName, cause);
}
- catch (IOException ex)
- {
- log.warn("Cannot get state for: " + objectName, ex);
- }
return Bundle.UNINSTALLED;
}
@@ -198,6 +189,9 @@
{
assertNotUninstalled();
ObjectName providerBundle = bundle.loadClass(name);
+ if (providerBundle == null)
+ return null;
+
String bundleId = providerBundle.getKeyProperty(ManagedBundle.PROPERTY_ID);
return getRuntime().getBundle(new Long(bundleId));
}
Show replies by date