diff options
author | Thomas Watson | 2015-01-29 22:45:32 +0000 |
---|---|---|
committer | Thomas Watson | 2015-01-29 22:53:44 +0000 |
commit | 21b4fbcbd9f5913556d5c2245fd48736dae6f449 (patch) | |
tree | 5ef448ad437c74a2c419f1ce6cc9cd8a29f60782 | |
parent | b13949ab8502d500c9ce4111bd419cf1af7bd5dc (diff) | |
download | rt.equinox.framework-21b4fbcbd9f5913556d5c2245fd48736dae6f449.tar.gz rt.equinox.framework-21b4fbcbd9f5913556d5c2245fd48736dae6f449.tar.xz rt.equinox.framework-21b4fbcbd9f5913556d5c2245fd48736dae6f449.zip |
Bug 458778 - Need to protect against interrupt flag on threads doingI20150203-1300I20150129-1830
framework operations
Change-Id: I7997c02981bbcb911600ecd433c27dc41bda96c7
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
2 files changed, 35 insertions, 10 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java index 4d603a0f9..92048c5b4 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 IBM Corporation and others. + * Copyright (c) 2009, 2015 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,4 +272,22 @@ public class BundleInstallUpdateTests extends AbstractBundleTests { reg.unregister(); } } + + public void testInstallWithInterruption() { + Bundle test = null; + Thread.currentThread().interrupt(); + try { + test = installer.installBundle("test"); //$NON-NLS-1$ + } catch (BundleException e) { + fail("Unexpected failure", e); //$NON-NLS-1$ + } finally { + Thread.interrupted(); + try { + if (test != null) + test.uninstall(); + } catch (BundleException e) { + // nothing + } + } + } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java index 2db897851..360fa1306 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 IBM Corporation and others. + * Copyright (c) 2012, 2015 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 @@ -40,17 +40,24 @@ public class LockSet<T> { locks.put(t, lock); } } - boolean obtained = !lock.isHeldByCurrentThread() && lock.tryLock(time, unit); - if (obtained) { - synchronized (monitor) { - // must check that another thread did not remove the lock - // when unlocking while we were waiting to obtain the lock - if (!locks.containsKey(t)) { - locks.put(t, lock); + boolean previousInterruption = Thread.interrupted(); + try { + boolean obtained = !lock.isHeldByCurrentThread() && lock.tryLock(time, unit); + if (obtained) { + synchronized (monitor) { + // must check that another thread did not remove the lock + // when unlocking while we were waiting to obtain the lock + if (!locks.containsKey(t)) { + locks.put(t, lock); + } } } + return obtained; + } finally { + if (previousInterruption) { + Thread.currentThread().interrupt(); + } } - return obtained; } public void unlock(T t) { |