Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Gajnak2015-07-09 16:05:45 +0000
committerThomas Watson2015-07-09 16:05:45 +0000
commitbf1f2a7f4639ef15279e17d372b2703cde1408fe (patch)
tree04da46cba9187ced61ab77298217dc1f25ec63c0 /bundles
parentb8bcf2cf0c63015d52bd754e601189917a446748 (diff)
downloadrt.equinox.framework-bf1f2a7f4639ef15279e17d372b2703cde1408fe.tar.gz
rt.equinox.framework-bf1f2a7f4639ef15279e17d372b2703cde1408fe.tar.xz
rt.equinox.framework-bf1f2a7f4639ef15279e17d372b2703cde1408fe.zip
Bug 469549 - ThreadLocal leak when Equinox is embedded
Signed-off-by: Jim Gajnak <jgajnak@gmail.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java17
2 files changed, 16 insertions, 14 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java
index 633fbf41f..2bd9e9fb5 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java
@@ -159,12 +159,7 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa
final EquinoxReentrantLock stateChangeLock = new EquinoxReentrantLock();
private final EnumSet<ModuleEvent> stateTransitionEvents = EnumSet.noneOf(ModuleEvent.class);
private final EnumSet<Settings> settings;
- private final ThreadLocal<Boolean> inStartResolve = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return Boolean.FALSE;
- }
- };
+ private final ThreadLocal<Boolean> inStartResolve = new ThreadLocal<Boolean>();
private volatile State state = State.INSTALLED;
private volatile int startlevel;
private volatile long lastModified;
@@ -694,6 +689,10 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa
}
final boolean inStartResolve() {
- return inStartResolve.get().booleanValue();
+ Boolean value = inStartResolve.get();
+ if (value == null) {
+ return false;
+ }
+ return value.booleanValue();
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index 1eed9e0c4..a3bec344f 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -75,12 +75,7 @@ final class ModuleResolver {
private static final Collection<String> NON_PAYLOAD_CAPABILITIES = Arrays.asList(IdentityNamespace.IDENTITY_NAMESPACE);
static final Collection<String> NON_PAYLOAD_REQUIREMENTS = Arrays.asList(HostNamespace.HOST_NAMESPACE, ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
- final ThreadLocal<Boolean> threadResolving = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return Boolean.FALSE;
- }
- };
+ final ThreadLocal<Boolean> threadResolving = new ThreadLocal<Boolean>();
final ModuleContainerAdaptor adaptor;
/**
@@ -844,7 +839,7 @@ final class ModuleResolver {
}
ModuleResolutionReport resolve() {
- if (threadResolving.get().booleanValue()) {
+ if (threadResolving()) {
// throw up a runtime exception, if this is caused by a resolver hook
// then it will get caught at the call to the resolver hook and a proper exception is thrown
throw new IllegalStateException(Msg.ModuleResolver_RecursiveError);
@@ -1410,4 +1405,12 @@ final class ModuleResolver {
return null;
}
}
+
+ protected boolean threadResolving() {
+ Boolean resolvingValue = this.threadResolving.get();
+ if (resolvingValue == null) {
+ return false;
+ }
+ return resolvingValue.booleanValue();
+ }
}

Back to the top