diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/Protocol.h | 25 | ||||
-rw-r--r-- | cpp/src/Ice/LocatorInfo.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/LocatorI.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/proxy/AllTests.cpp | 13 |
6 files changed, 44 insertions, 6 deletions
diff --git a/cpp/include/Ice/Protocol.h b/cpp/include/Ice/Protocol.h index cf14d1b85a8..8470a4549d4 100644 --- a/cpp/include/Ice/Protocol.h +++ b/cpp/include/Ice/Protocol.h @@ -187,6 +187,31 @@ checkSupportedEncoding(const Ice::EncodingVersion& v) } } +// +// Either return the given encoding if not compatible, or the greatest +// supported encoding otherwise. +// +inline const Ice::EncodingVersion& +checkForCompatibleEncoding(const Ice::EncodingVersion& v) +{ + if(v.major != Ice::currentEncoding.major) + { + return v; // Unsupported encoding, return as is. + } + else if(v.minor < Ice::currentEncoding.minor) + { + return v; // Supported encoding. + } + else + { + // + // Unsupported but compatible, use the currently supported + // encoding, that's the best we can do. + // + return Ice::currentEncoding; + } +} + } #endif diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index 315bfdc33c6..6e51363f5ff 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -324,9 +324,9 @@ IceInternal::LocatorInfo::RequestCallback::response(const LocatorInfoPtr& locato if(_ref->isWellKnown() && !isSupported(_ref->getEncoding(), r->getEncoding())) { // - // If a well-known proxy and the returned proxy encoding isn't - // supported, we're done: there are no compatible endpoints - // we can use. + // If a well-known proxy and the returned proxy encoding + // isn't supported, we're done: there's no compatible + // endpoint we can use. // } else if(!r->isIndirect()) diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 4f75c9957e1..51f41bedd2b 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -87,7 +87,7 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation _handler(handler), _observer(observer), _state(StateUnsent), - _encoding(handler->getReference()->getEncoding()), + _encoding(checkForCompatibleEncoding(handler->getReference()->getEncoding())), _is(handler->getReference()->getInstance().get(), Ice::currentProtocolEncoding), _os(handler->getReference()->getInstance().get(), Ice::currentProtocolEncoding), _sent(false) diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 5ffa11d3b41..04e9eabdc02 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -426,7 +426,7 @@ IceInternal::OutgoingAsync::OutgoingAsync(const ObjectPrx& prx, const Ice::LocalObjectPtr& cookie) : AsyncResult(prx->ice_getCommunicator(), prx->__reference()->getInstance(), operation, delegate, cookie), _proxy(prx), - _encoding(prx->__reference()->getEncoding()) + _encoding(checkForCompatibleEncoding(prx->__reference()->getEncoding())) { } diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp index 2ebc6fbc22a..798f207dfab 100644 --- a/cpp/src/IceGrid/LocatorI.cpp +++ b/cpp/src/IceGrid/LocatorI.cpp @@ -187,7 +187,7 @@ public: // // Ensure the server supports the request encoding. // - if(proxy->ice_getEncodingVersion() < _encoding) + if(!IceInternal::isSupported(_encoding, proxy->ice_getEncodingVersion())) { exception(id, Ice::UnsupportedEncodingException(__FILE__, __LINE__, diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 65a817c5ba0..8715475f4a4 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -697,6 +697,19 @@ allTests(const Ice::CommunicatorPtr& communicator) cl10->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping(); cl->ice_collocationOptimized(false)->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping(); + // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the + // call will use the 1.1 encoding + string ref13 = "test -e 1.3:default -p 12010"; + Test::MyClassPrx cl13 = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy(ref13)); + cl13->ice_ping(); + try + { + cl13->end_ice_ping(cl13->begin_ice_ping()); + } + catch(const Ice::CollocationOptimizationException&) + { + } + try { // Send request with bogus 1.2 encoding. |