diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/src/main/java/IceInternal/LocatorInfo.java | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/java/src/Ice/src/main/java/IceInternal/LocatorInfo.java b/java/src/Ice/src/main/java/IceInternal/LocatorInfo.java index b75df85f3c8..037771cde5d 100644 --- a/java/src/Ice/src/main/java/IceInternal/LocatorInfo.java +++ b/java/src/Ice/src/main/java/IceInternal/LocatorInfo.java @@ -90,30 +90,36 @@ public final class LocatorInfo private abstract class Request { - synchronized public void + public void addCallback(Reference ref, Reference wellKnownRef, int ttl, GetEndpointsCallback cb) { RequestCallback callback = new RequestCallback(ref, ttl, cb); - if(_response) + synchronized(this) { - callback.response(_locatorInfo, _proxy); + if(!_response && _exception == null) + { + _callbacks.add(callback); + if(wellKnownRef != null) // This request is to resolve the endpoints of a cached well-known object ref + { + _wellKnownRefs.add(wellKnownRef); + } + if(!_sent) + { + _sent = true; + send(); + } + return; + } } - else if(_exception != null) + + if(_response) { - callback.exception(_locatorInfo, _exception); + callback.response(_locatorInfo, _proxy); } else { - _callbacks.add(callback); - if(wellKnownRef != null) // This request is to resolve the endpoints of a cached well-known object ref - { - _wellKnownRefs.add(wellKnownRef); - } - if(!_sent) - { - _sent = true; - send(); - } + assert(_exception != null); + callback.exception(_locatorInfo, _exception); } } @@ -125,17 +131,20 @@ public final class LocatorInfo _response = false; } - synchronized protected void + protected void response(Ice.ObjectPrx proxy) { - _locatorInfo.finishRequest(_ref, _wellKnownRefs, proxy, false); - _response = true; - _proxy = proxy; + synchronized(this) + { + _locatorInfo.finishRequest(_ref, _wellKnownRefs, proxy, false); + _response = true; + _proxy = proxy; + notifyAll(); + } for(RequestCallback callback : _callbacks) { callback.response(_locatorInfo, proxy); } - notifyAll(); } protected void @@ -145,12 +154,12 @@ public final class LocatorInfo { _locatorInfo.finishRequest(_ref, _wellKnownRefs, null, ex instanceof Ice.UserException); _exception = ex; - for(RequestCallback callback : _callbacks) - { - callback.exception(_locatorInfo, ex); - } notifyAll(); } + for(RequestCallback callback : _callbacks) + { + callback.exception(_locatorInfo, ex); + } } protected abstract void send(); |