You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:20:46 UTC

[sling-org-apache-sling-commons-classloader] 12/14: SLING-2232 : Package admin classloader should check bundle state

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.classloader-1.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-classloader.git

commit bf4f1394bf381aa68f0774187a239f427de627ec
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Sep 27 09:08:05 2011 +0000

    SLING-2232 : Package admin classloader should check bundle state
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/classloader@1176288 13f79535-47bb-0310-9956-ffa450edef68
---
 .../commons/classloader/impl/PackageAdminClassLoader.java      | 10 +++++++++-
 .../sling/commons/classloader/impl/ClassLoadingTest.java       |  4 ++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java b/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
index 0c869b7..fb3bed9 100644
--- a/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
+++ b/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
@@ -67,7 +67,15 @@ class PackageAdminClassLoader extends ClassLoader {
      */
     private Bundle findBundleForPackage(final String pckName) {
         final ExportedPackage exportedPackage = this.packageAdmin.getExportedPackage(pckName);
-        final Bundle bundle = (exportedPackage == null ? null : exportedPackage.getExportingBundle());
+        Bundle bundle = null;
+        if (exportedPackage != null && !exportedPackage.isRemovalPending() ) {
+            bundle = exportedPackage.getExportingBundle();
+            if ( bundle != null ) {
+                if ( bundle.getState() != Bundle.ACTIVE ) {
+                    bundle = null;
+                }
+            }
+        }
         return bundle;
     }
 
diff --git a/src/test/java/org/apache/sling/commons/classloader/impl/ClassLoadingTest.java b/src/test/java/org/apache/sling/commons/classloader/impl/ClassLoadingTest.java
index 2c2d5a0..a5497c4 100644
--- a/src/test/java/org/apache/sling/commons/classloader/impl/ClassLoadingTest.java
+++ b/src/test/java/org/apache/sling/commons/classloader/impl/ClassLoadingTest.java
@@ -61,8 +61,12 @@ public class ClassLoadingTest {
             will(returnValue(ep));
             allowing(ep).getExportingBundle();
             will(returnValue(bundle));
+            allowing(ep).isRemovalPending();
+            will(returnValue(false));
             allowing(bundle).getBundleId();
             will(returnValue(2L));
+            allowing(bundle).getState();
+            will(returnValue(Bundle.ACTIVE));
             one(bundle).loadClass("org.apache.sling.test.A"); inSequence(sequence);
             will(returnValue(java.util.Map.class));
             one(bundle).loadClass("org.apache.sling.test.A"); inSequence(sequence);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.