modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java | 24 ---------- 1 file changed, 2 insertions(+), 22 deletions(-)
New commits: commit 014545b4e2ac3ac07413ffae42a2b06e0e5926ed Author: Lukas Krejci lkrejci@redhat.com Date: Wed Apr 3 20:17:49 2013 +0200
[BZ 928971] - Set the correct classloader for the dynamically created resource proxy classes.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java index fd85128..e15cb39 100644 --- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java +++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java @@ -152,7 +152,7 @@ public class ResourceClientFactory { private Class<?> defineCustomInterface(ResourceClientProxy proxy) { try { // define the dynamic class - do not put it in any known rhq package in case our jars are signed (see BZ-794503) - ClassPool pool = ClassPoolFactory.getClassPoolForCurrentContextClassLoader(); + ClassPool pool = ClassPoolFactory.getClassPool(ResourceClientProxy.class.getClassLoader()); CtClass customClass = pool.makeInterface("org.rhq.bindings.client.dynamic." + ResourceClientProxy.class.getSimpleName() + proxy.fingerprint);
@@ -209,13 +209,7 @@ public class ResourceClientFactory { } }
- ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - setContextClassLoader(ResourceClientProxy.class.getClassLoader()); - return customClass.toClass(); - } finally { - setContextClassLoader(cl); - } + return customClass.toClass(); } catch (NotFoundException e) { LOG.error("Could not create custom interface for resource with id " + proxy.getId(), e); throw new IllegalStateException("Could not create custom interface for resource with id " + proxy.getId(), e); @@ -227,18 +221,4 @@ public class ResourceClientFactory { throw new IllegalStateException("Could not create custom interface for resource with id " + proxy.getId(), e); } } - - private void setContextClassLoader(final ClassLoader cl) { - if (System.getSecurityManager() != null) { - AccessController.doPrivileged(new PrivilegedAction<Void>() { - @Override - public Void run() { - Thread.currentThread().setContextClassLoader(cl); - return null; - } - }); - } else { - Thread.currentThread().setContextClassLoader(cl); - } - } }
rhq-commits@lists.fedorahosted.org