Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 228584 Details for
Bug 403628
Asynchronous context shutdown causes timeouts during LifecycleManager#maybeCloseApplicationContextFor(Bundle) in Apache Felix
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for the extenderConfiguration and LifecycleManager to make asynchronous context shutdown configurable.
403628-against-master.patch (text/plain), 9.86 KB, created by
Olaf Otto
on 2013-03-18 13:54:52 EDT
(
hide
)
Description:
Patch for the extenderConfiguration and LifecycleManager to make asynchronous context shutdown configurable.
Filename:
MIME Type:
Creator:
Olaf Otto
Created:
2013-03-18 13:54:52 EDT
Size:
9.86 KB
patch
obsolete
>From 1f3a795c8eb9a421857989213e33b2923437ff4e Mon Sep 17 00:00:00 2001 >From: "Olaf Otto" <olaf.otto@unic.com> >Date: Mon, 18 Mar 2013 18:52:06 +0100 >Subject: [PATCH] 403628: Asynchronous context shutdown causes timeouts during > LifecycleManager#maybeCloseApplicationContextFor(Bundle) in > Apache Felix > (https://bugs.eclipse.org/bugs/show_bug.cgi?id=403628) > >--- > .../internal/activator/LifecycleManager.java | 28 ++++++++++------- > .../internal/support/ExtenderConfiguration.java | 35 +++++++++++++++++++--- > .../ExtenderConfigurationCustomSettingsTest.java | 6 +++- > .../ExtenderConfigurationDefaultSettingsTest.java | 6 +++- > .../internal/support/extender-custom-config.xml | 1 + > 5 files changed, 59 insertions(+), 17 deletions(-) > >diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java >index b2d5e43..a43bcab 100644 >--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java >+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java >@@ -271,25 +271,31 @@ class LifecycleManager implements DisposableBean { > * @param bundle > */ > protected void maybeCloseApplicationContextFor(Bundle bundle) { >- final ConfigurableOsgiBundleApplicationContext context = >- (ConfigurableOsgiBundleApplicationContext) managedContexts.remove(Long.valueOf(bundle.getBundleId())); >+ final ConfigurableOsgiBundleApplicationContext context = managedContexts.remove(bundle.getBundleId()); > if (context == null) { > return; > } > >- RunnableTimedExecution.execute(new Runnable() { >+ Runnable shutdownTask = new Runnable() { > >- private final String toString = "Closing runnable for context " + context.getDisplayName(); >+ private final String toString = "Closing runnable for context " + context.getDisplayName(); > >- public void run() { >- closeApplicationContext(context); >- } >+ public void run() { >+ closeApplicationContext(context); >+ } > >- public String toString() { >- return toString; >- } >+ public String toString() { >+ return toString; >+ } >+ >+ }; >+ >+ if (extenderConfiguration.shouldShutdownAsynchronously()) { >+ RunnableTimedExecution.execute(shutdownTask, extenderConfiguration.getShutdownWaitTime(), shutdownTaskExecutor); >+ } else { >+ shutdownTask.run(); >+ } > >- }, extenderConfiguration.getShutdownWaitTime(), shutdownTaskExecutor); > } > > /** >diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java >index 78560ce..765be66 100644 >--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java >+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java >@@ -42,7 +42,12 @@ import org.springframework.util.ObjectUtils; > import java.io.UnsupportedEncodingException; > import java.net.URL; > import java.net.URLDecoder; >-import java.util.*; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Enumeration; >+import java.util.List; >+import java.util.Properties; >+import java.util.Timer; > > /** > * Configuration class for the extender. Takes care of locating the extender specific configurations and merging the >@@ -67,6 +72,8 @@ public class ExtenderConfiguration implements BundleActivator { > > private static final String PROPERTIES_NAME = "extenderProperties"; > >+ private static final String SHUTDOWN_ASYNCHRONOUS_KEY = "shutdown.asynchronously"; >+ > private static final String SHUTDOWN_WAIT_KEY = "shutdown.wait.time"; > > private static final String PROCESS_ANNOTATIONS_KEY = "process.annotations"; >@@ -91,7 +98,9 @@ public class ExtenderConfiguration implements BundleActivator { > // default dependency wait time (in milliseconds) > private static final long DEFAULT_DEP_WAIT = ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000; > private static final boolean DEFAULT_NS_BUNDLE_STATE = true; >- private static final long DEFAULT_SHUTDOWN_WAIT = 10 * 1000; >+ private static final boolean DEFAULT_SHUTDOWN_ASYNCHRONOUS = true; >+ private static final long DEFAULT_SHUTDOWN_WAIT = 10 * 1000; >+ > private static final boolean DEFAULT_PROCESS_ANNOTATION = false; > > private ConfigurableOsgiBundleApplicationContext extenderConfiguration; >@@ -106,6 +115,8 @@ public class ExtenderConfiguration implements BundleActivator { > > private long shutdownWaitTime, dependencyWaitTime; > >+ private boolean shutdownAsynchronously; >+ > private boolean processAnnotation, nsBundledResolved; > > private OsgiBundleApplicationContextEventMulticaster eventMulticaster; >@@ -128,7 +139,7 @@ public class ExtenderConfiguration implements BundleActivator { > // fields reading/writing lock > private final Object lock = new Object(); > >- /** >+ /** > * Constructs a new <code>ExtenderConfiguration</code> instance. Locates the extender configuration, creates an > * application context which will returned the extender items. > * >@@ -209,7 +220,8 @@ public class ExtenderConfiguration implements BundleActivator { > > synchronized (lock) { > shutdownWaitTime = getShutdownWaitTime(properties); >- dependencyWaitTime = getDependencyWaitTime(properties); >+ shutdownAsynchronously = getShutdownAsynchronously(properties); >+ dependencyWaitTime = getDependencyWaitTime(properties); > processAnnotation = getProcessAnnotations(properties); > } > >@@ -302,6 +314,7 @@ public class ExtenderConfiguration implements BundleActivator { > private Properties createDefaultProperties() { > Properties properties = new Properties(); > properties.setProperty(SHUTDOWN_WAIT_KEY, "" + DEFAULT_SHUTDOWN_WAIT); >+ properties.setProperty(SHUTDOWN_ASYNCHRONOUS_KEY, "" + DEFAULT_SHUTDOWN_ASYNCHRONOUS); > properties.setProperty(PROCESS_ANNOTATIONS_KEY, "" + DEFAULT_PROCESS_ANNOTATION); > properties.setProperty(WAIT_FOR_DEPS_TIMEOUT_KEY, "" + DEFAULT_DEP_WAIT); > >@@ -388,6 +401,10 @@ public class ExtenderConfiguration implements BundleActivator { > return Long.parseLong(properties.getProperty(SHUTDOWN_WAIT_KEY)); > } > >+ private boolean getShutdownAsynchronously(Properties properties) { >+ return Boolean.valueOf(properties.getProperty(SHUTDOWN_ASYNCHRONOUS_KEY)); >+ } >+ > private long getDependencyWaitTime(Properties properties) { > return Long.parseLong(properties.getProperty(WAIT_FOR_DEPS_TIMEOUT_KEY)); > } >@@ -452,6 +469,16 @@ public class ExtenderConfiguration implements BundleActivator { > } > } > >+ /** >+ * @return whether the application context shutdown during the bundle stop phase shall be >+ * performed asynchronously. >+ */ >+ public boolean shouldShutdownAsynchronously() { >+ synchronized (lock) { >+ return this.shutdownAsynchronously; >+ } >+ } >+ > /** > * Returns the dependencyWaitTime. > * >diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationCustomSettingsTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationCustomSettingsTest.java >index 8a58d2a..ece5843 100644 >--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationCustomSettingsTest.java >+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationCustomSettingsTest.java >@@ -80,7 +80,11 @@ public class ExtenderConfigurationCustomSettingsTest extends TestCase { > assertEquals(300, config.getShutdownWaitTime()); > } > >- public void testShouldProcessAnnotation() throws Exception { >+ public void testShutdownAsynchronously() throws Exception { >+ assertFalse(config.shouldShutdownAsynchronously()); >+ } >+ >+ public void testShouldProcessAnnotation() throws Exception { > assertTrue(config.shouldProcessAnnotation()); > } > >diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationDefaultSettingsTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationDefaultSettingsTest.java >index 7f02cb5..736b04d 100644 >--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationDefaultSettingsTest.java >+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationDefaultSettingsTest.java >@@ -66,7 +66,11 @@ public class ExtenderConfigurationDefaultSettingsTest extends TestCase { > assertEquals(10 * 1000, config.getShutdownWaitTime()); > } > >- public void testShouldProcessAnnotation() throws Exception { >+ public void testShutdownAsynchronously() throws Exception { >+ assertTrue(config.shouldShutdownAsynchronously()); >+ } >+ >+ public void testShouldProcessAnnotation() throws Exception { > assertFalse(config.shouldProcessAnnotation()); > } > >diff --git a/extender/src/test/resources/org/eclipse/gemini/blueprint/extender/internal/support/extender-custom-config.xml b/extender/src/test/resources/org/eclipse/gemini/blueprint/extender/internal/support/extender-custom-config.xml >index d6157b6..6b4dcb8 100644 >--- a/extender/src/test/resources/org/eclipse/gemini/blueprint/extender/internal/support/extender-custom-config.xml >+++ b/extender/src/test/resources/org/eclipse/gemini/blueprint/extender/internal/support/extender-custom-config.xml >@@ -24,6 +24,7 @@ > <prop key="smth">bla</prop> > <prop key="dependencies.wait.time">200</prop> > <prop key="shutdown.wait.time">300</prop> >+ <prop key="shutdown.asynchronously">false</prop> > <prop key="process.annotations">true</prop> > </util:properties> > </beans> >\ No newline at end of file >-- >1.8.0.msysgit.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 403628
:
228584
|
228646