Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboshev2008-11-27 15:28:30 +0000
committersboshev2008-11-27 15:28:30 +0000
commit69ce32a32091fdf9926a0bca4f9cd74048c639eb (patch)
tree20c936e7a1c2504fdac5c8f8bb408695d9cc39df /bundles/org.eclipse.equinox.util
parentbbe32f00e325c6e1a22a959db44610104250eb9c (diff)
downloadrt.equinox.bundles-69ce32a32091fdf9926a0bca4f9cd74048c639eb.tar.gz
rt.equinox.bundles-69ce32a32091fdf9926a0bca4f9cd74048c639eb.tar.xz
rt.equinox.bundles-69ce32a32091fdf9926a0bca4f9cd74048c639eb.zip
Bug 250967. [ds] Component Resolve Thread gets a null context classloader
Diffstat (limited to 'bundles/org.eclipse.equinox.util')
-rw-r--r--bundles/org.eclipse.equinox.util/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/threadpool/Executor.java32
2 files changed, 13 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.util/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.util/META-INF/MANIFEST.MF
index 40d357032..425c82288 100644
--- a/bundles/org.eclipse.equinox.util/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.util/META-INF/MANIFEST.MF
@@ -23,4 +23,4 @@ Export-Package:
org.eclipse.equinox.internal.util.security;x-internal:=true,
org.eclipse.equinox.internal.util.threadpool;version="1.0";x-friends:="org.eclipse.equinox.ds",
org.eclipse.equinox.internal.util.timer;version="1.0";x-friends:="org.eclipse.equinox.ds,org.eclipse.equinox.ip"
-Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.0
+Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.1
diff --git a/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/threadpool/Executor.java b/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/threadpool/Executor.java
index 38e3cc003..11340223c 100644
--- a/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/threadpool/Executor.java
+++ b/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/threadpool/Executor.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.internal.util.impl.tpt.threadpool;
-import java.lang.reflect.Method;
import java.security.*;
import org.eclipse.equinox.internal.util.UtilActivator;
import org.eclipse.equinox.internal.util.impl.tpt.ServiceFactoryImpl;
@@ -20,21 +19,9 @@ import org.eclipse.equinox.internal.util.threadpool.ThreadContext;
/**
* @author Pavlin Dobrev
- * @version 1.0
*/
-
public class Executor extends Thread implements ThreadContext {
- static Method setCCL;
- static Object[] args;
- static {
- try {
- setCCL = Thread.class.getMethod("setContextClassLoader", new Class[] {ClassLoader.class});
- args = new Object[] {null};
- } catch (Throwable ignore) {
- }
- }
-
public static final String iname = "[ThreadPool Manager] - Idle Thread";
public static final String nullname = "[ThreadPool Manager] - Occupied Thread ";
public static final String xname = "ThreadPool Manager Thread";
@@ -48,9 +35,13 @@ public class Executor extends Thread implements ThreadContext {
AccessControlContext acc;
PEA pea;
+ static ClassLoader defaultTCCL;
- public synchronized void setRunnable(Runnable job, String name, ThreadPoolFactoryImpl factory, AccessControlContext acc) {
+ static {
+ defaultTCCL = Thread.currentThread().getContextClassLoader();
+ }
+ public synchronized void setRunnable(Runnable job, String name, ThreadPoolFactoryImpl factory, AccessControlContext acc) {
this.job = job;
this.factory = factory;
@@ -69,7 +60,6 @@ public class Executor extends Thread implements ThreadContext {
if (UtilActivator.debugLevel == 2 && UtilActivator.LOG_DEBUG) {
UtilActivator.log.debug(0x0100, 10003, getName(), null, false);
}
-
accessed = true;
if (acc != null) {
if (pea == null)
@@ -87,6 +77,10 @@ public class Executor extends Thread implements ThreadContext {
ServiceFactoryImpl.log.error("[ThreadPool Manager]\r\nException while executing: \r\nNAME: " + this + "\r\nJOB: " + job + "\r\n", t);
}
+ } finally {
+ if (getContextClassLoader() != defaultTCCL) {
+ setContextClassLoader(defaultTCCL);
+ }
}
if (UtilActivator.debugLevel == 2 && UtilActivator.LOG_DEBUG) {
UtilActivator.log.debug(0x0100, 10004, getName(), null, false);
@@ -129,11 +123,9 @@ public class Executor extends Thread implements ThreadContext {
public Executor() {
super(ServiceFactoryImpl.useNames ? iname : xname);
- if (setCCL != null)
- try {
- setCCL.invoke(this, args);
- } catch (Throwable ignore) {
- }
+ if (getContextClassLoader() != defaultTCCL) {
+ setContextClassLoader(defaultTCCL);
+ }
start();
}

Back to the top