Permalink
Browse files

ARIES-829 Update our code to be more tolerant of an IllegalStateExcep…

…tion when calling ctx.ungetService(). This only happens when the referenced service has gone, so the effect is the same.

Also update the ReferenceListRecipe.ServiceDispatcher.destroy to use the right bundle context when calling unget.

All in an attempt to make me less of a grumpy curmudgeon.

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk@1244183 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent a677a53 commit 018698617441c7befba2c9f3f7bccfe5db7fbe5a @NottyCode NottyCode committed Feb 14, 2012
@@ -192,9 +192,13 @@ public synchronized void destroy() {
proxy = null;
Bundle bundle = ref.getBundle();
if (bundle != null) {
- BundleContext ctx = bundle.getBundleContext();
+ BundleContext ctx = getBundleContextForServiceLookup();
if (ctx != null) {
- ctx.ungetService(ref);
+ try {
+ ctx.ungetService(ref);
+ } catch (IllegalStateException ise) {
+ // we don't care it doesn't exist so, shrug.
+ }
}
}
}
@@ -164,7 +164,11 @@ private void bind(ServiceReference ref) {
voidProxiedChildren();
bind(trackedServiceReference, proxy);
if (oldReference != null) {
+ try {
getBundleContextForServiceLookup().ungetService(oldReference);
+ } catch (IllegalStateException ise) {
+ // In case the service no longer exists lets just cope and ignore.
+ }
}
monitor.notifyAll();
}
@@ -179,7 +183,11 @@ private void unbind() {
trackedServiceReference = null;
trackedService = null;
voidProxiedChildren();
- getBundleContextForServiceLookup().ungetService(oldReference);
+ try {
+ getBundleContextForServiceLookup().ungetService(oldReference);
+ } catch (IllegalStateException ise) {
+ // In case the service no longer exists lets just cope and ignore.
+ }
monitor.notifyAll();
}
}

0 comments on commit 0186986

Please sign in to comment.