summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.cpp5
-rw-r--r--cpp/src/Ice/Proxy.cpp4
-rw-r--r--cs/src/Ice/ConnectRequestHandler.cs5
-rw-r--r--cs/src/Ice/Proxy.cs4
-rw-r--r--java/src/Ice/ObjectPrxHelperBase.java8
-rw-r--r--java/src/IceInternal/ConnectRequestHandler.java5
-rw-r--r--js/src/Ice/ConnectRequestHandler.js48
-rw-r--r--js/src/Ice/ConnectionRequestHandler.js28
-rw-r--r--js/src/Ice/ObjectPrx.js38
9 files changed, 79 insertions, 66 deletions
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp
index 7a6b495a13f..5a9a84c83b1 100644
--- a/cpp/src/Ice/ConnectRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectRequestHandler.cpp
@@ -92,11 +92,10 @@ RequestHandlerPtr
ConnectRequestHandler::connect()
{
Ice::ObjectPrx proxy = _proxy;
-
- _reference->getConnection(this);
-
try
{
+ _reference->getConnection(this);
+
Lock sync(*this);
if(!initialized())
{
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 2d7ef940fa7..f455f5e6361 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -1644,10 +1644,10 @@ void
IceProxy::Ice::Object::__setRequestHandler(const ::IceInternal::RequestHandlerPtr& previous,
const ::IceInternal::RequestHandlerPtr& handler)
{
- if(_reference->getCacheConnection())
+ if(_reference->getCacheConnection() && previous)
{
IceUtil::Mutex::Lock sync(_mutex);
- if(_requestHandler.get() != handler.get())
+ if(_requestHandler && _requestHandler.get() != handler.get())
{
//
// Update the request handler only if "previous" is the same
diff --git a/cs/src/Ice/ConnectRequestHandler.cs b/cs/src/Ice/ConnectRequestHandler.cs
index f1f552e6857..7676ee84d55 100644
--- a/cs/src/Ice/ConnectRequestHandler.cs
+++ b/cs/src/Ice/ConnectRequestHandler.cs
@@ -39,11 +39,10 @@ namespace IceInternal
public RequestHandler connect()
{
Ice.ObjectPrxHelperBase proxy = _proxy;
-
- _reference.getConnection(this);
-
try
{
+ _reference.getConnection(this);
+
lock(this)
{
if(!initialized())
diff --git a/cs/src/Ice/Proxy.cs b/cs/src/Ice/Proxy.cs
index a8b15699571..4f8edfe1b34 100644
--- a/cs/src/Ice/Proxy.cs
+++ b/cs/src/Ice/Proxy.cs
@@ -2442,11 +2442,11 @@ namespace Ice
public void setRequestHandler__(IceInternal.RequestHandler previous, IceInternal.RequestHandler handler)
{
- if(_reference.getCacheConnection())
+ if(_reference.getCacheConnection() && previous != null)
{
lock(this)
{
- if(_requestHandler != handler)
+ if(_requestHandler != null && _requestHandler != handler)
{
//
// Update the request handler only if "previous" is the same
diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java
index 031a2608466..00f7b9a30de 100644
--- a/java/src/Ice/ObjectPrxHelperBase.java
+++ b/java/src/Ice/ObjectPrxHelperBase.java
@@ -2783,15 +2783,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
public void
__setRequestHandler(IceInternal.RequestHandler previous, IceInternal.RequestHandler handler)
{
- if(_reference.getCacheConnection())
+ if(_reference.getCacheConnection() && previous != null)
{
synchronized(this)
{
- if(_requestHandler == null)
- {
- _requestHandler = handler;
- }
- else if(_requestHandler != handler)
+ if(_requestHandler != null && _requestHandler != handler)
{
//
// Update the request handler only if "previous" is the same
diff --git a/java/src/IceInternal/ConnectRequestHandler.java b/java/src/IceInternal/ConnectRequestHandler.java
index 19fca77610d..91957af1a0c 100644
--- a/java/src/IceInternal/ConnectRequestHandler.java
+++ b/java/src/IceInternal/ConnectRequestHandler.java
@@ -36,11 +36,10 @@ public class ConnectRequestHandler
connect()
{
Ice.ObjectPrxHelperBase proxy = _proxy;
-
- _reference.getConnection(this);
-
try
{
+ _reference.getConnection(this);
+
synchronized(this)
{
if(!initialized())
diff --git a/js/src/Ice/ConnectRequestHandler.js b/js/src/Ice/ConnectRequestHandler.js
index 45d76293f9a..e18aa92db7f 100644
--- a/js/src/Ice/ConnectRequestHandler.js
+++ b/js/src/Ice/ConnectRequestHandler.js
@@ -63,27 +63,41 @@ var ConnectRequestHandler = Ice.Class({
connect: function()
{
var self = this;
- this._reference.getConnection().then(
- function(connection, compress)
- {
- self.setConnection(connection, compress);
- }).exception(
- function(ex)
- {
- self.setException(ex);
- });
-
- if(this.initialized())
+ var proxy = this._proxy;
+ try
{
- Debug.assert(this._connection !== null);
- return new ConnectionRequestHandler(this._reference, this._connection, this._compress);
+ this._reference.getConnection().then(
+ function(connection, compress)
+ {
+ self.setConnection(connection, compress);
+ }).exception(
+ function(ex)
+ {
+ self.setException(ex);
+ });
+
+ if(!this.initialized())
+ {
+ // The proxy request handler will be updated when the connection is set.
+ this._updateRequestHandler = true;
+ return this;
+ }
}
- else
+ catch(ex)
{
- // The proxy request handler will be updated when the connection is set.
- this._updateRequestHandler = true;
- return this;
+ proxy.__setRequestHandler(this, null);
+ throw ex;
}
+
+ Debug.Assert(_connection != null);
+
+ var handler = new ConnectionRequestHandler(this._reference, this._connection, this._compress);
+ proxy.setRequestHandler__(this, handler);
+ return handler;
+ },
+ update: function(previousHandler, newHandler)
+ {
+ return previousHandler === this ? newHandler : this;
},
prepareBatchRequest: function(os)
{
diff --git a/js/src/Ice/ConnectionRequestHandler.js b/js/src/Ice/ConnectionRequestHandler.js
index c5e342b4315..5f4c3ff60b1 100644
--- a/js/src/Ice/ConnectionRequestHandler.js
+++ b/js/src/Ice/ConnectionRequestHandler.js
@@ -21,6 +21,34 @@ var ConnectionRequestHandler = Ice.Class({
this._connection = connection;
this._compress = compress;
},
+ // connect : function()
+ // {
+ // This request handler is only created after connection binding.
+ // }
+ update: function(previousHandler, newHandler)
+ {
+ try
+ {
+ if(previousHandler === this)
+ {
+ return newHandler;
+ }
+ else if(previousHandler.getConnection() === this._connection)
+ {
+ //
+ // If both request handlers point to the same connection, we also
+ // update the request handler. See bug ICE-5489 for reasons why
+ // this can be useful.
+ //
+ return newHandler;
+ }
+ }
+ catch(ex)
+ {
+ // Ignore
+ }
+ return this;
+ },
prepareBatchRequest: function(out)
{
this._connection.prepareBatchRequest(out);
diff --git a/js/src/Ice/ObjectPrx.js b/js/src/Ice/ObjectPrx.js
index 687ed354a79..2473843b521 100644
--- a/js/src/Ice/ObjectPrx.js
+++ b/js/src/Ice/ObjectPrx.js
@@ -583,54 +583,32 @@ var ObjectPrx = Ice.Class({
},
__getRequestHandler: function()
{
+ var handler;
if(this._reference.getCacheConnection())
{
if(this._requestHandler !== null)
{
return this._requestHandler;
}
- this._requestHandler = this.__createRequestHandler();
- return this._requestHandler;
+ this._requestHandler = new ConnectRequestHandler(this._reference, this);
+ handler = this._requestHandler;
}
else
{
- return this.__createRequestHandler();
+ handler = new ConnectRequestHandler(this._reference, this);
}
+ return handler.connect();
},
__setRequestHandler: function(previous, handler)
{
- if(this._reference.getCacheConnection())
+ if(this._reference.getCacheConnection() && previous !== null)
{
- if(previous === this._requestHandler)
+ if(this._requestHandler && this._requestHandler !== handler)
{
- this._requestHandler = handler;
- }
- else if(previous !== null && this._requestHandler !== null)
- {
- try
- {
- //
- // If both request handlers point to the same connection, we also
- // update the request handler. See bug ICE-5489 for reasons why
- // this can be useful.
- //
- if(previous.getConnection() == this._requestHandler.getConnection())
- {
- this._requestHandler = handler;
- }
- }
- catch(ex)
- {
- // Ignore
- }
+ this._requestHandler = this._requestHandler.update(previous, handler);
}
}
},
- __createRequestHandler: function()
- {
- var handler = new ConnectRequestHandler(this._reference, this);
- return handler.connect();
- },
//
// Only for use by IceInternal.ProxyFactory
//