Array index out of bounds exception occurred when creating protection
domain since it was doing a BundleImpl.toString() before adding the
module to the bundle. (FELIX-1170)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@785596 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index 20bda9b..b3e7cff 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -971,13 +971,16 @@
// TODO: Security
// sp.checkBundle(this);
}
- module.setSecurityContext(new BundleProtectionDomain(getFramework(), this));
IModule[] dest = new IModule[m_modules.length + 1];
System.arraycopy(m_modules, 0, dest, 0, m_modules.length);
dest[m_modules.length] = module;
m_modules = dest;
+ // Set protection domain after adding the module to the bundle,
+ // since this requires that the bundle has a module.
+ module.setSecurityContext(new BundleProtectionDomain(getFramework(), this));
+
// TODO: REFACTOR - consider moving ModuleImpl into the framework package
// so we can null module capabilities for extension bundles so we don't
// need this check anymore.