Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-09-27 22:20:45 +0000
committerThomas Watson2016-10-03 14:40:18 +0000
commitb04f7761908470d20a83e931ea420488bbe0f35c (patch)
tree841c611868bc27ccd2e022b788078761364838d4
parentb9b58fad679c8739a6a4019d353f4434ab9957fd (diff)
downloadrt.equinox.framework-b04f7761908470d20a83e931ea420488bbe0f35c.tar.gz
rt.equinox.framework-b04f7761908470d20a83e931ea420488bbe0f35c.tar.xz
rt.equinox.framework-b04f7761908470d20a83e931ea420488bbe0f35c.zip
Change-Id: I54fa1cce33e778d02a792b7c24a651c30555d08e Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java54
-rw-r--r--bundles/org.eclipse.osgi/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java9
-rw-r--r--bundles/org.eclipse.osgi/pom.xml2
5 files changed, 66 insertions, 4 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 983fabf9e..190927892 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -2887,4 +2887,58 @@ public class SystemBundleTests extends AbstractBundleTests {
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
}
+ public void testDaemonActiveThread() throws BundleException, InterruptedException {
+ File config = OSGiTestsActivator.getContext().getDataFile(getName());
+ config.mkdirs();
+ Map<String, Object> configuration = new HashMap<String, Object>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+
+ // test setting to anything other than 'normal'
+ // should result in a daemon thread
+ configuration.put(EquinoxConfiguration.PROP_ACTIVE_THREAD_TYPE, "daemon");
+ Equinox equinox = new Equinox(configuration);
+ equinox.start();
+ checkActiveThreadType(equinox, true);
+ equinox.stop();
+ equinox.waitForStop(10000);
+
+ // test setting to 'normal'
+ // should result in a non-daemon thread
+ configuration.put(EquinoxConfiguration.PROP_ACTIVE_THREAD_TYPE, EquinoxConfiguration.ACTIVE_THREAD_TYPE_NORMAL);
+ equinox = new Equinox(configuration);
+ equinox.start();
+ checkActiveThreadType(equinox, false);
+ equinox.stop();
+ equinox.waitForStop(10000);
+
+ // test setting to null (default)
+ // should result in a non-daemon thread
+ configuration.remove(EquinoxConfiguration.PROP_ACTIVE_THREAD_TYPE);
+ equinox = new Equinox(configuration);
+ equinox.start();
+ checkActiveThreadType(equinox, false);
+ equinox.stop();
+ }
+
+ void checkActiveThreadType(Equinox equinox, boolean expectIsDeamon) {
+ String uuid = equinox.getBundleContext().getProperty(Constants.FRAMEWORK_UUID);
+ ThreadGroup topGroup = Thread.currentThread().getThreadGroup();
+ if (topGroup != null) {
+ while (topGroup.getParent() != null) {
+ topGroup = topGroup.getParent();
+ }
+ }
+ Thread[] threads = new Thread[topGroup.activeCount()];
+ topGroup.enumerate(threads);
+ Thread found = null;
+ for (Thread t : threads) {
+ String name = t.getName();
+ if (("Active Thread: Equinox Container: " + uuid).equals(name)) {
+ found = t;
+ break;
+ }
+ }
+ assertNotNull("No framework active thread for \"" + uuid + "\" found in : " + Arrays.toString(threads), found);
+ assertEquals("Wrong daemon type.", expectIsDeamon, found.isDaemon());
+ }
}
diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
index d42e78f16..2c1d77bee 100644
--- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
@@ -95,7 +95,7 @@ Bundle-Activator: org.eclipse.osgi.internal.framework.SystemBundleActivator
Bundle-Description: %systemBundle
Bundle-Copyright: %copyright
Bundle-Vendor: %eclipse.org
-Bundle-Version: 3.11.1.qualifier
+Bundle-Version: 3.11.2.qualifier
Bundle-Localization: systembundle
Bundle-DocUrl: http://www.eclipse.org
Eclipse-ExtensibleAPI: true
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
index e2899c4f6..4fc048013 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
@@ -209,6 +209,9 @@ public class EquinoxConfiguration implements EnvironmentInfo {
public static final Collection<String> PROP_WITH_ECLIPSE_STARTER_DEFAULTS = Collections.singletonList(PROP_COMPATIBILITY_BOOTDELEGATION);
public static final String PROP_INIT_UUID = "equinox.init.uuid"; //$NON-NLS-1$
+ public static final String PROP_ACTIVE_THREAD_TYPE = "osgi.framework.activeThreadType"; //$NON-NLS-1$
+ public static final String ACTIVE_THREAD_TYPE_NORMAL = "normal"; //$NON-NLS-1$
+
public static final class ConfigValues {
/**
* Value of {@link #localConfig} properties that should be considered
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java
index def3ffde7..87011f38b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2015 IBM Corporation and others.
+ * Copyright (c) 2012, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -272,8 +272,13 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
@Override
public Thread newThread(Runnable r) {
+ String type = equinoxConfig.getConfiguration(EquinoxConfiguration.PROP_ACTIVE_THREAD_TYPE, EquinoxConfiguration.ACTIVE_THREAD_TYPE_NORMAL);
Thread t = new Thread(r, "Active Thread: " + toString()); //$NON-NLS-1$
- t.setDaemon(false);
+ if (EquinoxConfiguration.ACTIVE_THREAD_TYPE_NORMAL.equals(type)) {
+ t.setDaemon(false);
+ } else {
+ t.setDaemon(true);
+ }
t.setPriority(Thread.NORM_PRIORITY);
return t;
}
diff --git a/bundles/org.eclipse.osgi/pom.xml b/bundles/org.eclipse.osgi/pom.xml
index c0ca22cd2..b2c24bcdb 100644
--- a/bundles/org.eclipse.osgi/pom.xml
+++ b/bundles/org.eclipse.osgi/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
- <version>3.11.1-SNAPSHOT</version>
+ <version>3.11.2-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>

Back to the top