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:47:34 UTC

svn commit: r816113 - /camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java

Author: ningjiang
Date: Thu Sep 17 09:47:33 2009
New Revision: 816113

URL: http://svn.apache.org/viewvc?rev=816113&view=rev
Log:
Merged revisions 816105 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r816105 | ningjiang | 2009-09-17 17:23:10 +0800 (Thu, 17 Sep 2009) | 1 line
  
  CAMEL-2020 fixed the NPE of the OsgiFactoryFinder
........

Modified:
    camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java

Modified: camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java?rev=816113&r1=816112&r2=816113&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java (original)
+++ camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java Thu Sep 17 09:47:33 2009
@@ -82,8 +82,17 @@
     public BundleEntry getResource(String name) {
         URL url = null;
         BundleEntry entry = null;
+        Bundle[] bundles = null;       
         BundleContext bundleContext = Activator.getBundle().getBundleContext();
-        for (Bundle bundle : bundleContext.getBundles()) {            
+        if (bundleContext == null) {
+            // Bundle is not in STARTING|ACTIVE|STOPPING state
+            // (See OSGi 4.1 spec, section 4.3.17)
+            bundles = new Bundle[] {Activator.getBundle()};
+        } else {
+            bundles = bundleContext.getBundles();
+        }
+        
+        for (Bundle bundle : bundles) {
             url = bundle.getEntry(getPath() + name);
             if (url != null) {
                 entry = new BundleEntry();