njbartlett/Extensions2Services

ReflectionBinder should gracefully ignore non defined unbind methods

Closed this issue · 2 comments

pke commented

Currently it throws an exception if there is no unbind method defined. However sometimes its just not needed (ie. AbstractHandler subclass with injected services). Therefore the unbind method should not throw when the unbind method on the object class cannot be found.
Also the bind methods should be possible to be protected.

pke commented

java.lang.reflect.InvocationTargetException
at name.neilbartlett.extsvcs.core.internal.WeakCollection.accept(WeakCollection.java:25)
at name.neilbartlett.extsvcs.core.internal.SingletonBindTracker.removedService(SingletonBindTracker.java:55)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:922)
at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:351)
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:865)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:933)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:756)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:711)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:224)
at rapi4j.internal.ActiveSyncDeviceImpl.dispose(ActiveSyncDeviceImpl.java:66)
at rapi4j.internal.ActiveSyncServiceImpl$1$1.onLogDisconnection(ActiveSyncServiceImpl.java:166)
Caused by: name.neilbartlett.extsvcs.core.internal.BindingException: java.lang.NoSuchMethodException: rapi4j.ui.softreset.internal.ResetHandler.unsetActiveSyncDevice(rapi4j.ActiveSyncDevice)
at name.neilbartlett.extsvcs.core.internal.ReflectionBinder.unbind(ReflectionBinder.java:48)
at name.neilbartlett.extsvcs.core.internal.SingletonBindTracker$2.visit(SingletonBindTracker.java:57)
at name.neilbartlett.extsvcs.core.internal.WeakCollection.accept(WeakCollection.java:23)
... 13 more
Caused by: java.lang.NoSuchMethodException: rapi4j.ui.softreset.internal.ResetHandler.unsetActiveSyncDevice(rapi4j.ActiveSyncDevice)
at java.lang.Class.getDeclaredMethod(Class.java:1909)
at name.neilbartlett.extsvcs.core.internal.ReflectionBinder.unbind(ReflectionBinder.java:37)
... 15 more
java.io.IOException: Returned by WSARecv or WSARecvFrom to indicate the remote party has initiated a graceful shutdown sequence.
at rapi4j.internal.RapiHelper.checkRapiError(RapiHelper.java:96)
at rapi4j.internal.RapiHelper.checkRapiError(RapiHelper.java:77)
at rapi4j.internal.RapiHelper.getMemoryStatus(RapiHelper.java:126)
at rapi4j.internal.ActiveSyncDeviceImpl.getMemoryStatus(ActiveSyncDeviceImpl.java:108)
at rapi4j.internal.MemoryStatusProvider$1.run(MemoryStatusProvider.java:31)

The unbind problem has been fixed in the latest commit. It is not yet possible to have protected bind/unbind methods; I will raise this as a separate issue.