Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-02-17 21:18:08 +0000
committerThomas Watson2016-02-17 21:18:08 +0000
commitb56fb6c8cab11946c5aab9ac981f3182bbab6455 (patch)
tree1c3465f04895b4f73970fe2b9b5d44e497552bf3 /bundles
parent33c7f42010a0bd10d01fb0eaf3c7a6db43e64b74 (diff)
downloadrt.equinox.framework-b56fb6c8cab11946c5aab9ac981f3182bbab6455.tar.gz
rt.equinox.framework-b56fb6c8cab11946c5aab9ac981f3182bbab6455.tar.xz
rt.equinox.framework-b56fb6c8cab11946c5aab9ac981f3182bbab6455.zip
Bug 487842 - Unable to acquire state change lock for the module when
starting a bundle - Give cause for BundleException to improve debugging. Change-Id: I31c91e258c841b01c3abdd1ff325201f74cc6c6e Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java18
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/ExternalMessages.properties2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/Msg.java2
3 files changed, 19 insertions, 3 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 868e9b937..846635f96 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
@@ -10,15 +10,16 @@
*******************************************************************************/
package org.eclipse.osgi.container;
-import java.util.Arrays;
-import java.util.EnumSet;
+import java.util.*;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.osgi.container.ModuleContainerAdaptor.ModuleEvent;
import org.eclipse.osgi.internal.container.EquinoxReentrantLock;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.messages.Msg;
import org.eclipse.osgi.report.resolution.ResolutionReport;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.*;
import org.osgi.framework.startlevel.BundleStartLevel;
import org.osgi.framework.wiring.BundleRevision;
@@ -293,6 +294,7 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa
boolean invalid = false;
try {
boolean acquired = stateChangeLock.tryLock(revisions.getContainer().getModuleLockTimeout(), TimeUnit.SECONDS);
+ Set<ModuleEvent> currentTransition = Collections.emptySet();
if (acquired) {
boolean isValidTransition = true;
switch (transitionEvent) {
@@ -315,14 +317,24 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa
break;
}
if (!isValidTransition) {
+ currentTransition = EnumSet.copyOf(stateTransitionEvents);
invalid = true;
stateChangeLock.unlock();
} else {
stateTransitionEvents.add(transitionEvent);
return;
}
+ } else {
+ currentTransition = EnumSet.copyOf(stateTransitionEvents);
}
- throw new BundleException(Msg.Module_LockError + toString() + " " + transitionEvent + " " + stateTransitionEvents + (invalid ? " invalid" : ""), BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Throwable cause;
+ if (invalid) {
+ cause = new IllegalStateException(NLS.bind(Msg.Module_LockStateError, transitionEvent, currentTransition));
+ } else {
+ cause = new TimeoutException(NLS.bind(Msg.Module_LockTimeout, revisions.getContainer().getModuleLockTimeout()));
+ }
+ String exceptonInfo = toString() + ' ' + transitionEvent + ' ' + currentTransition;
+ throw new BundleException(Msg.Module_LockError + exceptonInfo, BundleException.STATECHANGE_ERROR, cause);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new BundleException(Msg.Module_LockError + toString() + " " + transitionEvent, BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/ExternalMessages.properties b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/ExternalMessages.properties
index 20a587352..dc3660828 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/ExternalMessages.properties
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/ExternalMessages.properties
@@ -114,6 +114,8 @@ EclipseStarter_InstallLocation=No install location found.
Module_Fragment_InvalidOperation=Invalid operation on a fragment.
Module_LockError=Unable to acquire the state change lock for the module:
+Module_LockStateError=Cannot transition to the state \"{0}\" while already in the process of transition to the following states: {1}
+Module_LockTimeout=Timeout after waiting {0} seconds to acquire the lock.
Module_ResolveError=Could not resolve module:
Module_StartError=Error starting module.
Module_StopError=Error stopping module.
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/Msg.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/Msg.java
index 973048ddb..fffc117e0 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/Msg.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/messages/Msg.java
@@ -121,6 +121,8 @@ public class Msg extends NLS {
public static String Module_Fragment_InvalidOperation;
public static String Module_LockError;
+ public static String Module_LockStateError;
+ public static String Module_LockTimeout;
public static String Module_ResolveError;
public static String Module_StartError;

Back to the top