summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ConnectionI.cpp14
-rw-r--r--cpp/test/Ice/operations/BatchOneways.cpp30
2 files changed, 43 insertions, 1 deletions
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index d5b92374617..9db70725047 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -604,7 +604,19 @@ Ice::ConnectionI::prepareBatchRequest(BasicStream* os)
if(_exception.get())
{
- _exception->ice_throw();
+ //
+ // If there were no batch requests queued when the connection failed, we can safely
+ // retry with a new connection. Otherwise, we must throw to notify the caller that
+ // some previous batch requests were not sent.
+ //
+ if(_batchStream.b.empty())
+ {
+ throw LocalExceptionWrapper(*_exception.get(), true);
+ }
+ else
+ {
+ _exception->ice_throw();
+ }
}
assert(_state > StateNotValidated);
diff --git a/cpp/test/Ice/operations/BatchOneways.cpp b/cpp/test/Ice/operations/BatchOneways.cpp
index 2ac5faab6f9..577f5ddcaef 100644
--- a/cpp/test/Ice/operations/BatchOneways.cpp
+++ b/cpp/test/Ice/operations/BatchOneways.cpp
@@ -63,4 +63,34 @@ batchOneways(const Test::MyClassPrx& p)
}
batch->ice_getConnection()->flushBatchRequests();
+
+ Test::MyClassPrx batch2 = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway());
+
+ batch->ice_ping();
+ batch2->ice_ping();
+ batch->ice_flushBatchRequests();
+ batch->ice_getConnection()->close(false);
+ batch->ice_ping();
+ batch2->ice_ping();
+
+ batch->ice_ping();
+ batch->ice_getConnection()->close(false);
+ try
+ {
+ batch->ice_ping();
+ test(false);
+ }
+ catch(const Ice::CloseConnectionException&)
+ {
+ }
+ try
+ {
+ batch2->ice_ping();
+ test(false);
+ }
+ catch(const Ice::CloseConnectionException&)
+ {
+ }
+ batch->ice_ping();
+ batch2->ice_ping();
}