diff options
author | Benoit Foucher <benoit@zeroc.com> | 2013-01-15 18:46:12 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2013-01-15 18:46:12 +0100 |
commit | f561241d76b7a3d58a8652a8ae6642361f6d596b (patch) | |
tree | 06602625807c74e6476043eee42f304e15609592 /java/src | |
parent | Fixed(ICE-5184) -IceGridGUI will not allow me to enter port in connection cre... (diff) | |
download | ice-f561241d76b7a3d58a8652a8ae6642361f6d596b.tar.bz2 ice-f561241d76b7a3d58a8652a8ae6642361f6d596b.tar.xz ice-f561241d76b7a3d58a8652a8ae6642361f6d596b.zip |
Fixed ICE-5131 - parsing of -p <version> for proxies, tweaked UDP endpoint deprecation warning for -v/-e
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/Outgoing.java | 8 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingAsync.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/Protocol.java | 27 | ||||
-rw-r--r-- | java/src/IceInternal/ReferenceFactory.java | 26 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpointI.java | 28 |
5 files changed, 75 insertions, 18 deletions
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index b176fed16df..903cf328384 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -23,10 +23,10 @@ public final class Outgoing implements OutgoingMessageCallback _sent = false; _handler = handler; _observer = observer; - _encoding = Protocol.checkForCompatibleEncoding(handler.getReference().getEncoding()); + _encoding = Protocol.getCompatibleEncoding(handler.getReference().getEncoding()); _os = new BasicStream(_handler.getReference().getInstance(), Protocol.currentProtocolEncoding); - Protocol.checkSupportedProtocol(_handler.getReference().getProtocol()); + Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(_handler.getReference().getProtocol())); writeHeader(operation, mode, context); } @@ -44,9 +44,9 @@ public final class Outgoing implements OutgoingMessageCallback _sent = false; _handler = handler; _observer = observer; - _encoding = Protocol.checkForCompatibleEncoding(handler.getReference().getEncoding()); + _encoding = Protocol.getCompatibleEncoding(handler.getReference().getEncoding()); - Protocol.checkSupportedProtocol(_handler.getReference().getProtocol()); + Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(_handler.getReference().getProtocol())); writeHeader(operation, mode, context); } diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index 7e89ec96058..f65f1aa221d 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -15,7 +15,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa { super(prx.ice_getCommunicator(), ((Ice.ObjectPrxHelperBase)prx).__reference().getInstance(), operation, cb); _proxy = (Ice.ObjectPrxHelperBase)prx; - _encoding = Protocol.checkForCompatibleEncoding(_proxy.__reference().getEncoding()); + _encoding = Protocol.getCompatibleEncoding(_proxy.__reference().getEncoding()); } public void __prepare(String operation, Ice.OperationMode mode, java.util.Map<String, String> ctx, @@ -26,7 +26,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa _mode = mode; _sentSynchronously = false; - Protocol.checkSupportedProtocol(_proxy.__reference().getProtocol()); + Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(_proxy.__reference().getProtocol())); if(explicitCtx && ctx == null) { diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java index e1e88ce3511..e90a33bd64a 100644 --- a/java/src/IceInternal/Protocol.java +++ b/java/src/IceInternal/Protocol.java @@ -131,11 +131,36 @@ final public class Protocol } // + // Either return the given protocol if not compatible, or the greatest + // supported protocol otherwise. + // + static public Ice.ProtocolVersion + getCompatibleProtocol(Ice.ProtocolVersion v) + { + if(v.major != currentProtocol.major) + { + return v; // Unsupported protocol, return as is. + } + else if(v.minor < currentProtocol.minor) + { + return v; // Supported protocol. + } + else + { + // + // Unsupported but compatible, use the currently supported + // protocol, that's the best we can do. + // + return currentProtocol; + } + } + + // // Either return the given encoding if not compatible, or the greatest // supported encoding otherwise. // static public Ice.EncodingVersion - checkForCompatibleEncoding(Ice.EncodingVersion v) + getCompatibleEncoding(Ice.EncodingVersion v) { if(v.major != currentEncoding.major) { diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index 16283cf3dbd..b418ec5d80e 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -164,6 +164,7 @@ public final class ReferenceFactory int mode = Reference.ModeTwoway; boolean secure = false; Ice.EncodingVersion encoding = _instance.defaultsAndOverrides().defaultEncoding; + Ice.ProtocolVersion protocol = Ice.Util.Protocol_1_0; String adapter = ""; while(true) @@ -356,6 +357,25 @@ public final class ReferenceFactory break; } + case 'p': + { + if(argument == null) + { + throw new Ice.ProxyParseException("no argument provided for -p option in `" + s + "'"); + } + + try + { + protocol = Ice.Util.stringToProtocolVersion(argument); + } + catch(Ice.VersionParseException e) + { + throw new Ice.ProxyParseException("invalid protocol version `" + argument + "' in `" + s + + "':\n" + e.str); + } + break; + } + default: { Ice.ProxyParseException e = new Ice.ProxyParseException(); @@ -367,7 +387,7 @@ public final class ReferenceFactory if(beg == -1) { - return create(ident, facet, mode, secure, Ice.Util.Protocol_1_0, encoding, null, null, propertyPrefix); + return create(ident, facet, mode, secure, protocol, encoding, null, null, propertyPrefix); } java.util.ArrayList<EndpointI> endpoints = new java.util.ArrayList<EndpointI>(); @@ -457,7 +477,7 @@ public final class ReferenceFactory EndpointI[] endp = new EndpointI[endpoints.size()]; endpoints.toArray(endp); - return create(ident, facet, mode, secure, Ice.Util.Protocol_1_0, encoding, endp, null, propertyPrefix); + return create(ident, facet, mode, secure, protocol, encoding, endp, null, propertyPrefix); } else if(s.charAt(beg) == '@') { @@ -516,7 +536,7 @@ public final class ReferenceFactory e.str = "empty adapter id in `" + s + "'"; throw e; } - return create(ident, facet, mode, secure, Ice.Util.Protocol_1_0, encoding, null, adapter, propertyPrefix); + return create(ident, facet, mode, secure, protocol, encoding, null, adapter, propertyPrefix); } Ice.ProxyParseException ex = new Ice.ProxyParseException(); diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index 2398fc43c98..151c6b13599 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -106,7 +106,6 @@ final class UdpEndpointI extends EndpointI } _connect = true; - break; } else if(option.equals("-z")) { @@ -117,15 +116,28 @@ final class UdpEndpointI extends EndpointI } _compress = true; - break; } - else if(option == "-v") + else if(option.equals("-v") || option.equals("-e")) { - _instance.initializationData().logger.warning("deprecated udp endpoint option: -v"); - } - else if(option == "-e") - { - _instance.initializationData().logger.warning("deprecated udp endpoint option: -e"); + if(argument == null) + { + throw new Ice.EndpointParseException("no argument provided for " + option + " option in endpoint " + + "`udp " + str + "'"); + } + + try + { + Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); + if(v.major != 1 || v.minor != 0) + { + _instance.initializationData().logger.warning("deprecated udp endpoint option: " + option); + } + } + catch(Ice.VersionParseException e) + { + throw new Ice.EndpointParseException("invalid version `" + argument + "' in endpoint `udp " + + str + "':\n" + e.str); + } } else if(option.equals("--interface")) { |