I'm subscribing two different org.bushe.swing.event.ProxySubscriber instances using ReferenceStrength.STRONG that proxy to the same object. However, the double subscription check in ThreadSafeEventService does not detect the duplicate subscriber.
I think the reason for this is, that the resolving of the real object is done for the new object being subscribed only for ReferenceStrength.WEAK proxies and the check for duplicates in the existing subscribers resolves the proxied object regardless of the ReferenceStrength.
- Resolve of the new object being checked looks like so https://github.com/michaelbushe/EventBus/blob/master/src/org/bushe/swing/event/ThreadSafeEventService.java#L632
isWeakProxySubscriber = proxySubscriber.getReferenceStrength() == ReferenceStrength.WEAK;
if (isWeakProxySubscriber) {
realSubscriber = ((ProxySubscriber) subscriber).getProxiedSubscriber();
}
- Resolving of the existing subscribers looks like so https://github.com/michaelbushe/EventBus/blob/master/src/org/bushe/swing/event/ThreadSafeEventService.java#L2056
if (existingSubscriber instanceof ProxySubscriber) {
existingProxySubscriber = (ProxySubscriber) existingSubscriber;
existingSubscriber = existingProxySubscriber.getProxiedSubscriber();
if (existingProxySubscriber == null) {
removeProxySubscriber(existingProxySubscriber, iterator);
}
}
So in case of a ReferenceStrength.STRONG ProxySubscriber we end up comparing the ProxySubscriber (new subscriber) with the proxied object (existing subscriber) which will not match and the duplicate entry is not being detected properly.
I think we should treat both ways of resolving the object in the same way!?
I'm subscribing two different org.bushe.swing.event.ProxySubscriber instances using ReferenceStrength.STRONG that proxy to the same object. However, the double subscription check in ThreadSafeEventService does not detect the duplicate subscriber.
I think the reason for this is, that the resolving of the real object is done for the new object being subscribed only for ReferenceStrength.WEAK proxies and the check for duplicates in the existing subscribers resolves the proxied object regardless of the ReferenceStrength.
So in case of a ReferenceStrength.STRONG ProxySubscriber we end up comparing the ProxySubscriber (new subscriber) with the proxied object (existing subscriber) which will not match and the duplicate entry is not being detected properly.
I think we should treat both ways of resolving the object in the same way!?