diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-09-06 23:02:34 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-09-06 23:02:34 +0200 |
commit | 95520c8e5ffa5bfd41f3036f3a8de1f0a93667ec (patch) | |
tree | 93e6f4c8186450f06d7bc28cfdfee99c0c1c4f7f | |
parent | Fix bogus reference use in communicatorDestroy (diff) | |
download | ice-95520c8e5ffa5bfd41f3036f3a8de1f0a93667ec.tar.bz2 ice-95520c8e5ffa5bfd41f3036f3a8de1f0a93667ec.tar.xz ice-95520c8e5ffa5bfd41f3036f3a8de1f0a93667ec.zip |
Ensure ice_getCachedConnection doesn't return null after successfully returning a connection
See bug ICE-8467
4 files changed, 40 insertions, 17 deletions
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp index 6bcb1bbc0c3..7e8f02257c5 100644 --- a/cpp/src/Ice/ConnectRequestHandler.cpp +++ b/cpp/src/Ice/ConnectRequestHandler.cpp @@ -103,15 +103,20 @@ Ice::ConnectionIPtr ConnectRequestHandler::getConnection() { Lock sync(*this); - if(_exception) + // + // First check for the connection, it's important otherwise the user could first get a connection + // and then the exception if he tries to obtain the proxy cached connection mutiple times (the + // exception can be set after the connection is set if the flush of pending requests fails). + // + if(_connection) { - _exception->ice_throw(); - return 0; // Keep the compiler happy. + return _connection; } - else + else if(_exception) { - return _connection; + _exception->ice_throw(); } + return ICE_NULLPTR; } Ice::ConnectionIPtr diff --git a/csharp/src/Ice/ConnectRequestHandler.cs b/csharp/src/Ice/ConnectRequestHandler.cs index 4378f1761dc..b78c045b8f9 100644 --- a/csharp/src/Ice/ConnectRequestHandler.cs +++ b/csharp/src/Ice/ConnectRequestHandler.cs @@ -90,14 +90,20 @@ namespace IceInternal { lock(this) { - if(_exception != null) + // + // First check for the connection, it's important otherwise the user could first get a connection + // and then the exception if he tries to obtain the proxy cached connection mutiple times (the + // exception can be set after the connection is set if the flush of pending requests fails). + // + if(_connection != null) { - throw _exception; + return _connection; } - else + else if(_exception != null) { - return _connection; + throw _exception; } + return null; } } diff --git a/java-compat/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java b/java-compat/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java index aeb2f45649c..0905ba11e49 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java @@ -98,14 +98,20 @@ public class ConnectRequestHandler synchronized public ConnectionI getConnection() { - if(_exception != null) + // + // First check for the connection, it's important otherwise the user could first get a connection + // and then the exception if he tries to obtain the proxy cached connection mutiple times (the + // exception can be set after the connection is set if the flush of pending requests fails). + // + if(_connection != null) { - throw (Ice.LocalException)_exception.fillInStackTrace(); + return _connection; } - else + else if(_exception != null) { - return _connection; + throw (Ice.LocalException)_exception.fillInStackTrace(); } + return null; } // diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/ConnectRequestHandler.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/ConnectRequestHandler.java index 6e06368678f..f4de5b9cd85 100644 --- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/ConnectRequestHandler.java +++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/ConnectRequestHandler.java @@ -96,14 +96,20 @@ public class ConnectRequestHandler synchronized public com.zeroc.Ice.ConnectionI getConnection() { - if(_exception != null) + // + // First check for the connection, it's important otherwise the user could first get a connection + // and then the exception if he tries to obtain the proxy cached connection mutiple times (the + // exception can be set after the connection is set if the flush of pending requests fails). + // + if(_connection != null) { - throw (com.zeroc.Ice.LocalException)_exception.fillInStackTrace(); + return _connection; } - else + else if(_exception != null) { - return _connection; + throw (com.zeroc.Ice.LocalException)_exception.fillInStackTrace(); } + return null; } // |