You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/09/17 11:23:13 UTC
svn commit: r816105 -
/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
Author: ningjiang
Date: Thu Sep 17 09:23:10 2009
New Revision: 816105
URL: http://svn.apache.org/viewvc?rev=816105&view=rev
Log:
CAMEL-2020 fixed the NPE of the OsgiFactoryFinder
Modified:
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java?rev=816105&r1=816104&r2=816105&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java (original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java Thu Sep 17 09:23:10 2009
@@ -79,10 +79,18 @@
public BundleEntry getResource(String name) {
BundleEntry entry = null;
+ org.osgi.framework.Bundle[] bundles = null;
BundleContext bundleContext = Activator.getBundle().getBundleContext();
+ if (bundleContext == null) {
+ // Bundle is not in STARTING|ACTIVE|STOPPING state
+ // (See OSGi 4.1 spec, section 4.3.17)
+ bundles = new org.osgi.framework.Bundle[] {Activator.getBundle()};
+ } else {
+ bundles = bundleContext.getBundles();
+ }
URL url;
- for (Bundle bundle : bundleContext.getBundles()) {
+ for (Bundle bundle : bundles) {
url = bundle.getEntry(getResourcePath() + name);
if (url != null) {
entry = new BundleEntry();