summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/include/IceUtil/StringUtil.h5
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.cpp2
-rw-r--r--cpp/src/Ice/EndpointFactoryManager.cpp2
-rw-r--r--cpp/src/Ice/Instance.cpp26
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp2
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.cpp50
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp63
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp34
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp58
-rw-r--r--cpp/src/IcePatch2Lib/Util.cpp9
-rw-r--r--cpp/src/IceSSL/EndpointI.cpp34
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp63
-rw-r--r--cpp/test/Ice/proxy/AllTests.cpp21
-rw-r--r--cs/src/Ice/DefaultsAndOverrides.cs2
-rw-r--r--cs/src/Ice/EndpointFactoryManager.cs2
-rw-r--r--cs/src/Ice/ObjectAdapterI.cs2
-rw-r--r--cs/src/Ice/OpaqueEndpointI.cs40
-rw-r--r--cs/src/Ice/ReferenceFactory.cs68
-rw-r--r--cs/src/Ice/StringUtil.cs81
-rw-r--r--cs/src/Ice/TcpEndpointI.cs21
-rw-r--r--cs/src/Ice/UdpEndpointI.cs44
-rw-r--r--cs/src/Ice/Util.cs28
-rw-r--r--cs/src/IceSSL/EndpointI.cs21
-rw-r--r--cs/test/Ice/proxy/AllTests.cs23
-rw-r--r--java/src/Ice/ObjectAdapterI.java2
-rw-r--r--java/src/Ice/Util.java33
-rw-r--r--java/src/IceInternal/DefaultsAndOverrides.java2
-rw-r--r--java/src/IceInternal/EndpointFactoryManager.java2
-rw-r--r--java/src/IceInternal/OpaqueEndpointI.java38
-rw-r--r--java/src/IceInternal/ReferenceFactory.java71
-rw-r--r--java/src/IceInternal/TcpEndpointI.java28
-rw-r--r--java/src/IceInternal/UdpEndpointI.java61
-rw-r--r--java/src/IceSSL/EndpointI.java28
-rw-r--r--java/src/IceUtilInternal/StringUtil.java77
-rw-r--r--java/test/Ice/proxy/AllTests.java28
-rw-r--r--slice/Ice/Communicator.ice6
36 files changed, 693 insertions, 384 deletions
diff --git a/cpp/include/IceUtil/StringUtil.h b/cpp/include/IceUtil/StringUtil.h
index 4efd077dfb7..cb39efc02e5 100644
--- a/cpp/include/IceUtil/StringUtil.h
+++ b/cpp/include/IceUtil/StringUtil.h
@@ -23,9 +23,10 @@ namespace IceUtilInternal
ICE_UTIL_API std::string escapeString(const std::string&, const std::string&);
//
-// Remove escape sequences added by escapeString.
+// Remove escape sequences added by escapeString. Throws IllegalArgumentException
+// for an invalid input string.
//
-ICE_UTIL_API bool unescapeString(const std::string&, std::string::size_type, std::string::size_type, std::string&);
+ICE_UTIL_API std::string unescapeString(const std::string&, std::string::size_type, std::string::size_type);
//
// Split a string using the given delimiters. Considers single and double quotes;
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp
index 81572b0ec68..587b9d79717 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.cpp
+++ b/cpp/src/Ice/DefaultsAndOverrides.cpp
@@ -86,7 +86,7 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
else
{
EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
- ex.str = value;
+ ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
throw ex;
}
diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp
index 0c1e823712e..516f9dbbc44 100644
--- a/cpp/src/Ice/EndpointFactoryManager.cpp
+++ b/cpp/src/Ice/EndpointFactoryManager.cpp
@@ -72,7 +72,7 @@ IceInternal::EndpointFactoryManager::create(const string& str, bool oaEndpoint)
if(beg == string::npos)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "value has no non-whitespace characters";
throw ex;
}
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 24540c65491..f42191c8246 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -406,7 +406,7 @@ IceInternal::Instance::stringToIdentity(const string& s) const
// Extra unescaped slash found.
//
IdentityParseException ex(__FILE__, __LINE__);
- ex.str = s;
+ ex.str = "unescaped backslash in identity `" + s + "'";
throw ex;
}
}
@@ -415,27 +415,39 @@ IceInternal::Instance::stringToIdentity(const string& s) const
if(slash == string::npos)
{
- if(!IceUtilInternal::unescapeString(s, 0, s.size(), ident.name))
+ try
+ {
+ ident.name = IceUtilInternal::unescapeString(s, 0, s.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
{
IdentityParseException ex(__FILE__, __LINE__);
- ex.str = s;
+ ex.str = "invalid identity name `" + s + "': " + e.reason();
throw ex;
}
}
else
{
- if(!IceUtilInternal::unescapeString(s, 0, slash, ident.category))
+ try
+ {
+ ident.category = IceUtilInternal::unescapeString(s, 0, slash);
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
{
IdentityParseException ex(__FILE__, __LINE__);
- ex.str = s;
+ ex.str = "invalid category in identity `" + s + "': " + e.reason();
throw ex;
}
if(slash + 1 < s.size())
{
- if(!IceUtilInternal::unescapeString(s, slash + 1, s.size(), ident.name))
+ try
+ {
+ ident.name = IceUtilInternal::unescapeString(s, slash + 1, s.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
{
IdentityParseException ex(__FILE__, __LINE__);
- ex.str = s;
+ ex.str = "invalid name in identity `" + s + "': " + e.reason();
throw ex;
}
}
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 69363ee91db..2c1ad771e36 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -1213,7 +1213,7 @@ Ice::ObjectAdapterI::parseEndpoints(const string& endpts, bool oaEndpoints) cons
if(endp == 0)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = s;
+ ex.str = "invalid object adapter endpoint `" + s + "'";
throw ex;
}
endpoints.push_back(endp);
diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp
index 9960872df1c..e4b1ee75215 100644
--- a/cpp/src/Ice/OpaqueEndpointI.cpp
+++ b/cpp/src/Ice/OpaqueEndpointI.cpp
@@ -46,7 +46,7 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
if(option.length() != 2 || option[0] != '-')
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "opaque " + str;
+ ex.str = "expected an endpoint option but found `" + option + "' in endpoint `opaque " + str + "'";
throw ex;
}
@@ -67,16 +67,34 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
{
case 't':
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -t option in endpoint `opaque " + str + "'";
+ throw ex;
+ }
istringstream p(argument);
Ice::Int t;
- if(!(p >> t) || !p.eof() || t < 0 || t > 65535)
+ if(!(p >> t) || !p.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "opaque " + str;
+ ex.str = "invalid timeout value `" + argument + "' in endpoint `opaque " + str + "'";
+ throw ex;
+ }
+ else if(t < 0 || t > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "timeout value `" + argument + "' out of range in endpoint `opaque " + str + "'";
throw ex;
}
_type = static_cast<Ice::Short>(t);
++topt;
+ if(topt > 1)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "multiple -t options in endpoint `opaque " + str + "'";
+ throw ex;
+ }
break;
}
@@ -85,7 +103,7 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "opaque " + str;
+ ex.str = "no argument provided for -v option in endpoint `opaque " + str + "'";
throw ex;
}
for(string::size_type i = 0; i < argument.size(); ++i)
@@ -93,27 +111,43 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
if(!Base64::isBase64(argument[i]))
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "opaque " + str;
+ ostringstream ostr;
+ ostr << "invalid base64 character `" << argument[i] << "' (ordinal " << (int)argument[i]
+ << ") in endpoint `opaque " << str << "'";
+ ex.str = ostr.str();
throw ex;
}
}
const_cast<vector<Byte>&>(_rawBytes) = Base64::decode(argument);
++vopt;
+ if(vopt > 1)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "multiple -v options in endpoint `opaque " + str + "'";
+ throw ex;
+ }
break;
}
default:
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "opaque " + str;
+ ex.str = "invalid option `" + option + "' in endpoint `opaque " + str + "'";
throw ex;
}
}
}
- if(topt != 1 || vopt != 1)
+
+ if(topt != 1)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no -t option in endpoint `opaque " + str + "'";
+ throw ex;
+ }
+ if(vopt != 1)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "opaque " + str;
+ ex.str = "no -v option in endpoint `opaque " + str + "'";
throw ex;
}
}
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index fb6c0d0327d..2881e3953a3 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -110,7 +110,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(beg == string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "no non-whitespace characters found in `" + s + "'";
throw ex;
}
@@ -123,7 +123,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(end == string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "mismatched quotes around identity in `" + s + "'";
throw ex;
}
else if(end == 0)
@@ -145,7 +145,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(beg == end)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "no identity in `" + s + "'";
throw ex;
}
@@ -174,7 +174,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
else if(s.find_first_not_of(delim, end) != string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "invalid characters after identity in `" + s + "'";
throw ex;
}
else
@@ -216,7 +216,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(option.length() != 2 || option[0] != '-')
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "expected a proxy option but found `" + option + "' in `" + s + "'";
throw ex;
}
@@ -236,7 +236,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(end == string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "mismatched quotes around value for " + option + " option in `" + s + "'";
throw ex;
}
else if(end == 0)
@@ -268,14 +268,18 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "no argument provided for -f option in `" + s + "'";
throw ex;
}
- if(!IceUtilInternal::unescapeString(argument, 0, argument.size(), facet))
+ try
+ {
+ facet = IceUtilInternal::unescapeString(argument, 0, argument.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "invalid facet in `" + s + "': " + e.reason();
throw ex;
}
@@ -288,7 +292,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(!argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'";
throw ex;
}
mode = Reference::ModeTwoway;
@@ -300,7 +304,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(!argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'";
throw ex;
}
mode = Reference::ModeOneway;
@@ -312,7 +316,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(!argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'";
throw ex;
}
mode = Reference::ModeBatchOneway;
@@ -324,7 +328,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(!argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'";
throw ex;
}
mode = Reference::ModeDatagram;
@@ -336,7 +340,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(!argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'";
throw ex;
}
mode = Reference::ModeBatchDatagram;
@@ -348,7 +352,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(!argument.empty())
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'";
throw ex;
}
secure = true;
@@ -358,7 +362,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
default:
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "unknown option `" + option + "' in `" + s + "'";
throw ex;
}
}
@@ -439,8 +443,9 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
}
if(endpoints.size() == 0)
{
+ assert(!unknownEndpoints.empty());
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = unknownEndpoints.front();
+ ex.str = "invalid endpoint `" + unknownEndpoints.front() + "' in `" + s + "'";
throw ex;
}
else if(unknownEndpoints.size() != 0 &&
@@ -464,7 +469,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(beg == string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "missing adapter id in `" + s + "'";
throw ex;
}
@@ -473,7 +478,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(end == string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "mismatched quotes around adapter id in `" + s + "'";
throw ex;
}
else if(end == 0)
@@ -496,14 +501,24 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
if(end != string::npos && s.find_first_not_of(delim, end) != string::npos)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "invalid trailing characters after `" + s.substr(0, end + 1) + "' in `" + s + "'";
throw ex;
}
- if(!IceUtilInternal::unescapeString(adapterstr, 0, adapterstr.size(), adapter) || adapter.size() == 0)
+ try
+ {
+ adapter = IceUtilInternal::unescapeString(adapterstr, 0, adapterstr.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid adapter id in `" + s + "': " + e.reason();
+ throw ex;
+ }
+ if(adapter.size() == 0)
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "empty adapter id in `" + s + "'";
throw ex;
}
@@ -515,7 +530,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
default:
{
ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
+ ex.str = "malformed proxy `" + s + "'";
throw ex;
}
}
@@ -771,7 +786,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
else
{
EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
- ex.str = type;
+ ex.str = "illegal value `" + type + "'; expected `Random' or `Ordered'";
throw ex;
}
}
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index c8e027b4ffb..3ac47c875bc 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -62,7 +62,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
if(option.length() != 2 || option[0] != '-')
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "expected an endpoint option but found `" + option + "' in endpoint `tcp " + str + "'";
throw ex;
}
@@ -90,7 +90,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "no argument provided for -h option in endpoint `tcp " + str + "'";
throw ex;
}
const_cast<string&>(_host) = argument;
@@ -99,11 +99,23 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
case 'p':
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -p option in endpoint `tcp " + str + "'";
+ throw ex;
+ }
istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid port value `" + argument + "' in endpoint `tcp " + str + "'";
+ throw ex;
+ }
+ else if(_port < 0 || _port > 65535)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "port value `" + argument + "' out of range in endpoint `tcp " + str + "'";
throw ex;
}
break;
@@ -111,11 +123,17 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
case 't':
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -t option in endpoint `tcp " + str + "'";
+ throw ex;
+ }
istringstream t(argument);
if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'";
throw ex;
}
break;
@@ -126,7 +144,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
if(!argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "unexpected argument `" + argument + "' provided for -z option in `tcp " + str + "'";
throw ex;
}
const_cast<bool&>(_compress) = true;
@@ -136,7 +154,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
default:
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "unknown option `" + option + "' in `tcp " + str + "'";
throw ex;
}
}
@@ -155,7 +173,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
else
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
+ ex.str = "`-h *' not valid for proxy endpoint `tcp " + str + "'";
throw ex;
}
}
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index 6d0ed5e6989..9119ece31f9 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -74,7 +74,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(option[0] != '-')
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'";
throw ex;
}
@@ -89,7 +89,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(end == string::npos)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
else
@@ -117,7 +117,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "no argument provided for -v option in endpoint `udp " + str + "'";
throw ex;
}
@@ -125,7 +125,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(pos == string::npos)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "malformed protocol version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
string majorStr = argument.substr(0, pos);
@@ -136,7 +136,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(!(majStr >> majVersion) || !majStr.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "invalid protocol major version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
@@ -145,14 +145,14 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(!(minStr >> minVersion) || !minStr.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "invalid protocol minor version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "range error in protocol version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
@@ -174,7 +174,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "no argument provided for -e option in endpoint `udp " + str + "'";
throw ex;
}
string::size_type pos = argument.find('.');
@@ -186,7 +186,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(!(majStr >> majVersion) || !majStr.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "invalid encoding major version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
@@ -195,14 +195,14 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(!(minStr >> minVersion) || !minStr.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "invalid encoding minor version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "range error in encoding version `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
@@ -224,18 +224,30 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "no argument provided for -h option in endpoint `udp " + str + "'";
throw ex;
}
const_cast<string&>(_host) = argument;
}
else if(option == "-p")
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -p option in endpoint `udp " + str + "'";
+ throw ex;
+ }
istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'";
+ throw ex;
+ }
+ else if(_port < 0 || _port > 65535)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'";
throw ex;
}
}
@@ -244,7 +256,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(!argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'";
throw ex;
}
const_cast<bool&>(_connect) = true;
@@ -254,7 +266,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(!argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'";
throw ex;
}
const_cast<bool&>(_compress) = true;
@@ -264,25 +276,31 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "no argument provided for --interface option in endpoint `udp " + str + "'";
throw ex;
}
const_cast<string&>(_mcastInterface) = argument;
}
else if(option == "--ttl")
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for --ttl option in endpoint `udp " + str + "'";
+ throw ex;
+ }
istringstream p(argument);
if(!(p >> const_cast<Int&>(_mcastTtl)) || !p.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'";
throw ex;
}
}
else
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "unknown option `" + option + "' in `udp " + str + "'";
throw ex;
}
}
@@ -300,7 +318,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
else
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
+ ex.str = "`-h *' not valid for proxy endpoint `udp " + str + "'";
throw ex;
}
}
diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp
index 0aeb63fbbf6..0d73f1df4c4 100644
--- a/cpp/src/IcePatch2Lib/Util.cpp
+++ b/cpp/src/IcePatch2Lib/Util.cpp
@@ -150,7 +150,14 @@ IcePatch2::readFileInfo(FILE* fp, FileInfo& info)
string s;
getline(is, s, '\t');
- IceUtilInternal::unescapeString(s, 0, s.size(), info.path);
+ try
+ {
+ info.path = IceUtilInternal::unescapeString(s, 0, s.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& ex)
+ {
+ throw ex.reason();
+ }
getline(is, s, '\t');
info.checksum = stringToBytes(s);
diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp
index 01e32c9c47a..d1b699d4859 100644
--- a/cpp/src/IceSSL/EndpointI.cpp
+++ b/cpp/src/IceSSL/EndpointI.cpp
@@ -62,7 +62,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
if(option.length() != 2 || option[0] != '-')
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "expected an endpoint option but found `" + option + "' in endpoint `ssl " + str + "'";
throw ex;
}
@@ -90,7 +90,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
if(argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "no argument provided for -h option in endpoint `ssl " + str + "'";
throw ex;
}
const_cast<string&>(_host) = argument;
@@ -99,11 +99,23 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
case 'p':
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -p option in endpoint `ssl " + str + "'";
+ throw ex;
+ }
istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid port value `" + argument + "' in endpoint `ssl " + str + "'";
+ throw ex;
+ }
+ else if(_port < 0 || _port > 65535)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "port value `" + argument + "' out of range in endpoint `ssl " + str + "'";
throw ex;
}
break;
@@ -111,11 +123,17 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
case 't':
{
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -t option in endpoint `ssl " + str + "'";
+ throw ex;
+ }
istringstream t(argument);
if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "invalid timeout value `" + argument + "' in endpoint `ssl " + str + "'";
throw ex;
}
break;
@@ -126,7 +144,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
if(!argument.empty())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "unexpected argument `" + argument + "' provided for -z option in `ssl " + str + "'";
throw ex;
}
const_cast<bool&>(_compress) = true;
@@ -136,7 +154,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
default:
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "unknown option `" + option + "' in `ssl " + str + "'";
throw ex;
}
}
@@ -155,7 +173,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo
else
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
+ ex.str = "`-h *' not valid for proxy endpoint `ssl " + str + "'";
throw ex;
}
}
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 3c65ad42dd7..296c5dd9cf6 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -161,11 +161,22 @@ namespace
{
char
-checkChar(char c)
+checkChar(const string& s, string::size_type pos)
{
- if(!(static_cast<unsigned char>(c) >= 32 && static_cast<unsigned char>(c) <= 126))
+ unsigned char c = static_cast<unsigned char>(s[pos]);
+ if(!(c >= 32 && c <= 126))
{
- throw IllegalArgumentException(__FILE__, __LINE__, "illegal input character");
+ ostringstream ostr;
+ if(pos > 0)
+ {
+ ostr << "character after `" << s.substr(0, pos) << "'";
+ }
+ else
+ {
+ ostr << "first character";
+ }
+ ostr << " is not a printable ASCII character (ordinal " << (int)c << ")";
+ throw IllegalArgumentException(__FILE__, __LINE__, ostr.str());
}
return c;
}
@@ -186,13 +197,13 @@ decodeChar(const string& s, string::size_type start, string::size_type end, stri
if(s[start] != '\\')
{
- c = checkChar(s[start++]);
+ c = checkChar(s, start++);
}
else
{
if(start + 1 == end)
{
- throw IllegalArgumentException(__FILE__, __LINE__, "trailing backslash in argument");
+ throw IllegalArgumentException(__FILE__, __LINE__, "trailing backslash");
}
switch(s[++start])
{
@@ -242,7 +253,7 @@ decodeChar(const string& s, string::size_type start, string::size_type end, stri
case '6':
case '7':
{
- int oct = 0;
+ int val = 0;
for(int j = 0; j < 3 && start < end; ++j)
{
int charVal = s[start++] - '0';
@@ -251,18 +262,20 @@ decodeChar(const string& s, string::size_type start, string::size_type end, stri
--start;
break;
}
- oct = oct * 8 + charVal;
+ val = val * 8 + charVal;
}
- if(oct > 255)
+ if(val > 255)
{
- throw IllegalArgumentException(__FILE__, __LINE__, "octal value out of range");
+ ostringstream ostr;
+ ostr << "octal value \\" << oct << val << dec << " (" << val << ") is out of range";
+ throw IllegalArgumentException(__FILE__, __LINE__, ostr.str());
}
- c = (char)oct;
+ c = (char)val;
break;
}
default:
{
- c = checkChar(s[start++]);
+ c = checkChar(s, start++);
break;
}
}
@@ -289,30 +302,16 @@ decodeString(const string& s, string::size_type start, string::size_type end, st
//
// Remove escape sequences added by escapeString.
//
-bool
-IceUtilInternal::unescapeString(const string& s, string::size_type start, string::size_type end, string& result)
+string
+IceUtilInternal::unescapeString(const string& s, string::size_type start, string::size_type end)
{
- if(end > s.size())
- {
- throw IllegalArgumentException(__FILE__, __LINE__, "end offset must be <= s.size()");
- }
- if(start > end)
- {
- throw IllegalArgumentException(__FILE__, __LINE__, "start offset must <= end offset");
- }
+ assert(start <= end && end <= s.size());
+ string result;
result.reserve(end - start);
-
- try
- {
- result.clear();
- decodeString(s, start, end, result);
- return true;
- }
- catch(...)
- {
- return false;
- }
+ result.clear();
+ decodeString(s, start, end, result);
+ return result;
}
bool
diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp
index 7165938a046..271f849d39a 100644
--- a/cpp/test/Ice/proxy/AllTests.cpp
+++ b/cpp/test/Ice/proxy/AllTests.cpp
@@ -93,6 +93,27 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" &&
b1->ice_getAdapterId().empty());
+ b1 = communicator->stringToProxy("");
+ test(!b1);
+ b1 = communicator->stringToProxy("\"\"");
+ test(!b1);
+ try
+ {
+ b1 = communicator->stringToProxy("\"\" test"); // Invalid trailing characters.
+ test(false);
+ }
+ catch(const Ice::ProxyParseException&)
+ {
+ }
+ try
+ {
+ b1 = communicator->stringToProxy("test:"); // Missing endpoint.
+ test(false);
+ }
+ catch(const Ice::EndpointParseException&)
+ {
+ }
+
b1 = communicator->stringToProxy("test@adapter");
test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
b1->ice_getAdapterId() == "adapter");
diff --git a/cs/src/Ice/DefaultsAndOverrides.cs b/cs/src/Ice/DefaultsAndOverrides.cs
index a74c4746e78..a5555a34a64 100644
--- a/cs/src/Ice/DefaultsAndOverrides.cs
+++ b/cs/src/Ice/DefaultsAndOverrides.cs
@@ -111,7 +111,7 @@ namespace IceInternal
else
{
Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
- ex.str = val;
+ ex.str = "illegal value `" + val + "'; expected `Random' or `Ordered'";
throw ex;
}
diff --git a/cs/src/Ice/EndpointFactoryManager.cs b/cs/src/Ice/EndpointFactoryManager.cs
index b91266d6b0a..db4b350a6e5 100644
--- a/cs/src/Ice/EndpointFactoryManager.cs
+++ b/cs/src/Ice/EndpointFactoryManager.cs
@@ -62,7 +62,7 @@ namespace IceInternal
if(s.Length == 0)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = str;
+ e.str = "value has no non-whitespace characters";
throw e;
}
diff --git a/cs/src/Ice/ObjectAdapterI.cs b/cs/src/Ice/ObjectAdapterI.cs
index b8037bbd199..be95413e19d 100644
--- a/cs/src/Ice/ObjectAdapterI.cs
+++ b/cs/src/Ice/ObjectAdapterI.cs
@@ -1236,7 +1236,7 @@ namespace Ice
continue;
}
Ice.EndpointParseException e2 = new Ice.EndpointParseException();
- e2.str = s;
+ e2.str = "invalid object adapter endpoint `" + s + "'";
throw e2;
}
endpoints.Add(endp);
diff --git a/cs/src/Ice/OpaqueEndpointI.cs b/cs/src/Ice/OpaqueEndpointI.cs
index 7524d14b0e1..e12cb50bca8 100644
--- a/cs/src/Ice/OpaqueEndpointI.cs
+++ b/cs/src/Ice/OpaqueEndpointI.cs
@@ -36,7 +36,8 @@ namespace IceInternal
string option = arr[i++];
if(option.Length != 2 || option[0] != '-')
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("expected an endpoint option but found `" + option +
+ "' in endpoint `opaque " + str + "'");
}
string argument = null;
@@ -51,7 +52,8 @@ namespace IceInternal
{
if(argument == null)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException(
+ "no argument provided for -t option in endpoint `opaque " + str + "'");
}
int t;
@@ -61,16 +63,23 @@ namespace IceInternal
}
catch(System.FormatException)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint `opaque " + str + "'");
}
if(t < 0 || t > 65535)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("timeout value `" + argument +
+ "' out of range in endpoint `opaque " + str + "'");
}
_type = (short)t;
++topt;
+ if(topt > 1)
+ {
+ throw new Ice.EndpointParseException("multiple -t options in endpoint `opaque " + str +
+ "'");
+ }
break;
}
@@ -78,30 +87,43 @@ namespace IceInternal
{
if(argument == null)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException(
+ "no argument provided for -v option in endpoint `opaque " + str + "'");
}
for(int j = 0; j < argument.Length; ++j)
{
if(!IceUtilInternal.Base64.isBase64(argument[j]))
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException(
+ "invalid base64 character `" + argument[j] + "' (ordinal " +
+ ((int)argument[j]) + ") in endpoint `opaque " + str + "'");
}
}
_rawBytes = IceUtilInternal.Base64.decode(argument);
++vopt;
+ if(vopt > 1)
+ {
+ throw new Ice.EndpointParseException("multiple -v options in endpoint `opaque " + str +
+ "'");
+ }
break;
}
default:
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("invalid option `" + option + "' in endpoint `opaque " +
+ str + "'");
}
}
}
- if(topt != 1 || vopt != 1)
+ if(topt != 1)
+ {
+ throw new Ice.EndpointParseException("no -t option in endpoint `opaque " + str + "'");
+ }
+ if(vopt != 1)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("no -v option in endpoint `opaque " + str + "'");
}
calcHashValue();
}
diff --git a/cs/src/Ice/ReferenceFactory.cs b/cs/src/Ice/ReferenceFactory.cs
index 0c3fa9891c5..3fab0d4c990 100644
--- a/cs/src/Ice/ReferenceFactory.cs
+++ b/cs/src/Ice/ReferenceFactory.cs
@@ -10,6 +10,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
namespace IceInternal
@@ -89,7 +90,7 @@ namespace IceInternal
if(beg == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "no non-whitespace characters found in `" + s + "'";
throw e;
}
@@ -102,7 +103,7 @@ namespace IceInternal
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "mismatched quotes around identity in `" + s + "'";
throw e;
}
else if(end == 0)
@@ -124,7 +125,7 @@ namespace IceInternal
if(beg == end)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "no identity in `" + s + "'";
throw e;
}
@@ -154,7 +155,7 @@ namespace IceInternal
else if(IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "invalid characters after identity in `" + s + "'";
throw e;
}
else
@@ -196,7 +197,7 @@ namespace IceInternal
if(option.Length != 2 || option[0] != '-')
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "expected a proxy option but found `" + option + "' in `" + s + "'";
throw e;
}
@@ -217,7 +218,7 @@ namespace IceInternal
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "mismatched quotes around value for " + option + " option in `" + s + "'";
throw e;
}
else if(end == 0)
@@ -249,18 +250,20 @@ namespace IceInternal
if(argument == null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "no argument provided for -f option in `" + s + "'";
throw e;
}
- string token;
- if(!IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.Length, out token))
+ try
+ {
+ facet = IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.Length);
+ }
+ catch(System.ArgumentException argEx)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "invalid facet in `" + s + "': " + argEx.Message;
throw e;
}
- facet = token;
break;
}
@@ -269,7 +272,7 @@ namespace IceInternal
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'";
throw e;
}
mode = Reference.Mode.ModeTwoway;
@@ -281,7 +284,7 @@ namespace IceInternal
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'";
throw e;
}
mode = Reference.Mode.ModeOneway;
@@ -293,7 +296,7 @@ namespace IceInternal
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'";
throw e;
}
mode = Reference.Mode.ModeBatchOneway;
@@ -305,7 +308,7 @@ namespace IceInternal
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'";
throw e;
}
mode = Reference.Mode.ModeDatagram;
@@ -317,7 +320,7 @@ namespace IceInternal
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'";
throw e;
}
mode = Reference.Mode.ModeBatchDatagram;
@@ -329,7 +332,7 @@ namespace IceInternal
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'";
throw e;
}
secure = true;
@@ -339,7 +342,7 @@ namespace IceInternal
default:
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unknown option `" + option + "' in `" + s + "'";
throw e;
}
}
@@ -417,8 +420,9 @@ namespace IceInternal
}
if(endpoints.Count == 0)
{
+ Debug.Assert(unknownEndpoints.Count > 0);
Ice.EndpointParseException e2 = new Ice.EndpointParseException();
- e2.str = s;
+ e2.str = "invalid endpoint `" + unknownEndpoints[0] + "' in `" + s + "'";
throw e2;
}
else if(unknownEndpoints.Count != 0 &&
@@ -445,7 +449,7 @@ namespace IceInternal
if(beg == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "missing adapter id in `" + s + "'";
throw e;
}
@@ -454,7 +458,7 @@ namespace IceInternal
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "mismatched quotes around adapter id in `" + s + "'";
throw e;
}
else if(end == 0)
@@ -476,22 +480,31 @@ namespace IceInternal
if(end != s.Length && IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "invalid trailing characters after `" + s.Substring(0, end + 1) + "' in `" + s + "'";
throw e;
}
- if(!IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length, out adapter) ||
- adapter.Length == 0)
+ try
+ {
+ adapter = IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length);
+ }
+ catch(System.ArgumentException argEx)
+ {
+ Ice.ProxyParseException e = new Ice.ProxyParseException();
+ e.str = "invalid adapter id in `" + s + "': " + argEx.Message;
+ throw e;
+ }
+ if(adapter.Length == 0)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "empty adapter id in `" + s + "'";
throw e;
}
return create(ident, facet, mode, secure, null, adapter, propertyPrefix);
}
Ice.ProxyParseException ex = new Ice.ProxyParseException();
- ex.str = s;
+ ex.str = "malformed proxy `" + s + "'";
throw ex;
}
@@ -774,7 +787,8 @@ namespace IceInternal
}
else
{
- throw new Ice.EndpointSelectionTypeParseException(type);
+ throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type +
+ "'; expected `Random' or `Ordered'");
}
}
diff --git a/cs/src/Ice/StringUtil.cs b/cs/src/Ice/StringUtil.cs
index dd5c1d584ca..9db9c17c697 100644
--- a/cs/src/Ice/StringUtil.cs
+++ b/cs/src/Ice/StringUtil.cs
@@ -180,7 +180,8 @@ namespace IceUtilInternal
{
if((int)special[i] < 32 || (int)special[i] > 126)
{
- throw new System.ArgumentException("special characters must be in ASCII range 32-126", "special");
+ throw new System.ArgumentException("special characters must be in ASCII range 32-126",
+ "special");
}
}
}
@@ -197,11 +198,22 @@ namespace IceUtilInternal
return result.ToString();
}
- private static char checkChar(char c)
+ private static char checkChar(string s, int pos)
{
+ char c = s[pos];
if(!(c >= 32 && c <= 126))
{
- throw new System.ArgumentException("illegal input character");
+ string msg;
+ if(pos > 0)
+ {
+ msg = "character after `" + s.Substring(0, pos) + "'";
+ }
+ else
+ {
+ msg = "first character";
+ }
+ msg += " is not a printable ASCII character (ordinal " + (int)c + ")";
+ throw new System.ArgumentException(msg);
}
return c;
}
@@ -222,13 +234,13 @@ namespace IceUtilInternal
if(s[start] != '\\')
{
- c = checkChar(s[start++]);
+ c = checkChar(s, start++);
}
else
{
if(start + 1 == end)
{
- throw new System.ArgumentException("trailing backslash in argument");
+ throw new System.ArgumentException("trailing backslash");
}
switch(s[++start])
{
@@ -278,7 +290,7 @@ namespace IceUtilInternal
case '6':
case '7':
{
- int oct = 0;
+ int val = 0;
for(int j = 0; j < 3 && start < end; ++j)
{
int charVal = s[start++] - '0';
@@ -287,18 +299,20 @@ namespace IceUtilInternal
--start;
break;
}
- oct = oct * 8 + charVal;
+ val = val * 8 + charVal;
}
- if(oct > 255)
+ if(val > 255)
{
- throw new System.ArgumentException("octal value out of range", "s");
+ string msg = "octal value \\" + System.Convert.ToString(val, 8) + " (" + val +
+ ") is out of range";
+ throw new System.ArgumentException(msg, "s");
}
- c = System.Convert.ToChar(oct);
+ c = System.Convert.ToChar(val);
break;
}
default:
{
- c = checkChar(s[start++]);
+ c = checkChar(s, start++);
break;
}
}
@@ -320,44 +334,25 @@ namespace IceUtilInternal
}
//
- // Remove escape sequences added by escapeString.
+ // Remove escape sequences added by escapeString. Throws System.ArgumentException
+ // for an invalid input string.
//
- public static bool unescapeString(string s, int start, int end, out string result)
+ public static string unescapeString(string s, int start, int end)
{
- if(start < 0)
- {
- throw new System.ArgumentException("start offset must be >= 0", "start");
- }
- if(end > s.Length)
- {
- throw new System.ArgumentException("end offset must be <= s.Length", "end");
- }
- if(start > end)
- {
- throw new System.ArgumentException("start offset must be <= end offset");
- }
-
- result = null;
- try
- {
- StringBuilder sb = new StringBuilder();
- decodeString(s, start, end, sb);
- string decodedString = sb.ToString();
+ Debug.Assert(start >= 0 && start <= end && end <= s.Length);
- byte[] arr = new byte[decodedString.Length];
- for(int i = 0; i < arr.Length; ++i)
- {
- arr[i] = (byte)decodedString[i];
- }
+ StringBuilder sb = new StringBuilder();
+ decodeString(s, start, end, sb);
+ string decodedString = sb.ToString();
- UTF8Encoding utf8 = new UTF8Encoding(false, true);
- result = utf8.GetString(arr);
- return true;
- }
- catch(System.Exception)
+ byte[] arr = new byte[decodedString.Length];
+ for(int i = 0; i < arr.Length; ++i)
{
- return false;
+ arr[i] = (byte)decodedString[i];
}
+
+ UTF8Encoding utf8 = new UTF8Encoding(false, true);
+ return utf8.GetString(arr); // May raise ArgumentException.
}
public static int checkQuote(string s)
diff --git a/cs/src/Ice/TcpEndpointI.cs b/cs/src/Ice/TcpEndpointI.cs
index 2202d4e3849..b7724d49d7b 100644
--- a/cs/src/Ice/TcpEndpointI.cs
+++ b/cs/src/Ice/TcpEndpointI.cs
@@ -52,7 +52,7 @@ namespace IceInternal
if(option.Length != 2 || option[0] != '-')
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "expected an endpoint option but found `" + option + "' in endpoint `tcp " + str + "'";
throw e;
}
@@ -73,7 +73,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "no argument provided for -h option in endpoint `tcp " + str + "'";
throw e;
}
@@ -86,7 +86,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "no argument provided for -p option in endpoint `tcp " + str + "'";
throw e;
}
@@ -97,14 +97,14 @@ namespace IceInternal
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "tcp " + str;
+ e.str = "invalid port value `" + argument + "' in endpoint `tcp " + str + "'";
throw e;
}
if(_port < 0 || _port > 65535)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "port value `" + argument + "' out of range in endpoint `tcp " + str + "'";
throw e;
}
@@ -116,7 +116,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "no argument provided for -t option in endpoint `tcp " + str + "'";
throw e;
}
@@ -127,7 +127,7 @@ namespace IceInternal
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "tcp " + str;
+ e.str = "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'";
throw e;
}
@@ -139,7 +139,8 @@ namespace IceInternal
if(argument != null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "unexpected argument `" + argument + "' provided for -z option in `tcp " + str +
+ "'";
throw e;
}
@@ -150,7 +151,7 @@ namespace IceInternal
default:
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "tcp " + str;
+ e.str = "unknown option `" + option + "' in `tcp " + str + "'";
throw e;
}
}
@@ -168,7 +169,7 @@ namespace IceInternal
}
else
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `tcp " + str + "'");
}
}
diff --git a/cs/src/Ice/UdpEndpointI.cs b/cs/src/Ice/UdpEndpointI.cs
index 0ed3b07af48..538d0564fa9 100644
--- a/cs/src/Ice/UdpEndpointI.cs
+++ b/cs/src/Ice/UdpEndpointI.cs
@@ -72,7 +72,7 @@ namespace IceInternal
if(option[0] != '-')
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'";
throw e;
}
@@ -87,7 +87,7 @@ namespace IceInternal
if(end == -1)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
else
@@ -115,7 +115,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "no argument provided for -v option in endpoint `udp " + str + "'";
throw e;
}
@@ -123,7 +123,7 @@ namespace IceInternal
if(pos == -1)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "malformed protocol version `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
@@ -139,14 +139,14 @@ namespace IceInternal
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "udp " + str;
+ e.str = "invalid protocol version `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "range error in protocol version `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
@@ -168,7 +168,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "no argument provided for -e option in endpoint `udp " + str + "'";
throw e;
}
@@ -176,7 +176,7 @@ namespace IceInternal
if(pos == -1)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "malformed encoding version `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
@@ -192,14 +192,14 @@ namespace IceInternal
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "udp " + str;
+ e.str = "invalid encoding version `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "range error in encoding version `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
@@ -221,7 +221,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "no argument provided for -h option in endpoint `udp " + str + "'";
throw e;
}
@@ -232,7 +232,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "no argument provided for -p option in endpoint `udp " + str + "'";
throw e;
}
@@ -243,14 +243,14 @@ namespace IceInternal
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "udp " + str;
+ e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
if(_port < 0 || _port > 65535)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'";
throw e;
}
}
@@ -259,7 +259,7 @@ namespace IceInternal
if(argument != null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'";
throw e;
}
@@ -270,7 +270,7 @@ namespace IceInternal
if(argument != null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'";
throw e;
}
@@ -281,7 +281,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "no argument provided for --interface option in endpoint `udp " + str + "'";
throw e;
}
@@ -292,7 +292,7 @@ namespace IceInternal
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'";
throw e;
}
@@ -303,21 +303,21 @@ namespace IceInternal
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "udp " + str;
+ e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'";
throw e;
}
if(_mcastTtl < 0)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'";
throw e;
}
}
else
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "udp " + str;
+ e.str = "unknown option `" + option + "' in `udp " + str + "'";
throw e;
}
}
@@ -334,7 +334,7 @@ namespace IceInternal
}
else
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'");
}
}
diff --git a/cs/src/Ice/Util.cs b/cs/src/Ice/Util.cs
index ff3294f7c14..3367922561b 100644
--- a/cs/src/Ice/Util.cs
+++ b/cs/src/Ice/Util.cs
@@ -226,7 +226,7 @@ namespace Ice
// Extra unescaped slash found.
//
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "unescaped backslash in identity `" + s + "'";
throw ex;
}
}
@@ -235,28 +235,40 @@ namespace Ice
if(slash == -1)
{
- if(!IceUtilInternal.StringUtil.unescapeString(s, 0, s.Length, out ident.name))
+ ident.category = "";
+ try
+ {
+ ident.name = IceUtilInternal.StringUtil.unescapeString(s, 0, s.Length);
+ }
+ catch(System.ArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "invalid identity name `" + s + "': " + e.Message;
throw ex;
}
- ident.category = "";
}
else
{
- if(!IceUtilInternal.StringUtil.unescapeString(s, 0, slash, out ident.category))
+ try
+ {
+ ident.category = IceUtilInternal.StringUtil.unescapeString(s, 0, slash);
+ }
+ catch(System.ArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "invalid category in identity `" + s + "': " + e.Message;
throw ex;
}
if(slash + 1 < s.Length)
{
- if(!IceUtilInternal.StringUtil.unescapeString(s, slash + 1, s.Length, out ident.name))
+ try
+ {
+ ident.name = IceUtilInternal.StringUtil.unescapeString(s, slash + 1, s.Length);
+ }
+ catch(System.ArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "invalid name in identity `" + s + "': " + e.Message;
throw ex;
}
}
diff --git a/cs/src/IceSSL/EndpointI.cs b/cs/src/IceSSL/EndpointI.cs
index 00cb51592fa..9c5eefb552f 100644
--- a/cs/src/IceSSL/EndpointI.cs
+++ b/cs/src/IceSSL/EndpointI.cs
@@ -52,7 +52,7 @@ namespace IceSSL
if(option.Length != 2 || option[0] != '-')
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "expected an endpoint option but found `" + option + "' in endpoint `ssl " + str + "'";
throw e;
}
@@ -73,7 +73,7 @@ namespace IceSSL
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "no argument provided for -h option in endpoint `ssl " + str + "'";
throw e;
}
@@ -86,7 +86,7 @@ namespace IceSSL
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "no argument provided for -p option in endpoint `ssl " + str + "'";
throw e;
}
@@ -97,14 +97,14 @@ namespace IceSSL
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "ssl " + str;
+ e.str = "invalid port value `" + argument + "' in endpoint `ssl " + str + "'";
throw e;
}
if(_port < 0 || _port > 65535)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "port value `" + argument + "' out of range in endpoint `ssl " + str + "'";
throw e;
}
@@ -116,7 +116,7 @@ namespace IceSSL
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "no argument provided for -t option in endpoint `ssl " + str + "'";
throw e;
}
@@ -127,7 +127,7 @@ namespace IceSSL
catch(System.FormatException ex)
{
Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "ssl " + str;
+ e.str = "invalid timeout value `" + argument + "' in endpoint `ssl " + str + "'";
throw e;
}
@@ -139,7 +139,8 @@ namespace IceSSL
if(argument != null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "unexpected argument `" + argument + "' provided for -z option in `ssl " + str +
+ "'";
throw e;
}
@@ -150,7 +151,7 @@ namespace IceSSL
default:
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "ssl " + str;
+ e.str = "unknown option `" + option + "' in `ssl " + str + "'";
throw e;
}
}
@@ -168,7 +169,7 @@ namespace IceSSL
}
else
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `ssl " + str + "'");
}
}
diff --git a/cs/test/Ice/proxy/AllTests.cs b/cs/test/Ice/proxy/AllTests.cs
index dccbb0173c4..3d6c49c22a2 100644
--- a/cs/test/Ice/proxy/AllTests.cs
+++ b/cs/test/Ice/proxy/AllTests.cs
@@ -98,7 +98,28 @@ public class AllTests
b1 = communicator.stringToProxy("category/test");
test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") &&
b1.ice_getAdapterId().Length == 0);
-
+
+ b1 = communicator.stringToProxy("");
+ test(b1 == null);
+ b1 = communicator.stringToProxy("\"\"");
+ test(b1 == null);
+ try
+ {
+ b1 = communicator.stringToProxy("\"\" test"); // Invalid trailing characters.
+ test(false);
+ }
+ catch(Ice.ProxyParseException)
+ {
+ }
+ try
+ {
+ b1 = communicator.stringToProxy("test:"); // Missing endpoint.
+ test(false);
+ }
+ catch(Ice.EndpointParseException)
+ {
+ }
+
b1 = communicator.stringToProxy("test@adapter");
test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 &&
b1.ice_getAdapterId().Equals("adapter"));
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java
index b4bd577a414..c0243872304 100644
--- a/java/src/Ice/ObjectAdapterI.java
+++ b/java/src/Ice/ObjectAdapterI.java
@@ -1211,7 +1211,7 @@ public final class ObjectAdapterI implements ObjectAdapter
if(endp == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = s;
+ e.str = "invalid object adapter endpoint `" + s + "'";
throw e;
}
endpoints.add(endp);
diff --git a/java/src/Ice/Util.java b/java/src/Ice/Util.java
index dc4253eb627..04ea0dea312 100644
--- a/java/src/Ice/Util.java
+++ b/java/src/Ice/Util.java
@@ -252,7 +252,7 @@ public final class Util
// Extra unescaped slash found.
//
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "unescaped backslash in identity `" + s + "'";
throw ex;
}
}
@@ -261,35 +261,42 @@ public final class Util
if(slash == -1)
{
- StringHolder token = new StringHolder();
- if(!IceUtilInternal.StringUtil.unescapeString(s, 0, s.length(), token))
+ ident.category = "";
+ try
+ {
+ ident.name = IceUtilInternal.StringUtil.unescapeString(s, 0, s.length());
+ }
+ catch(IllegalArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "invalid identity name `" + s + "': " + e.getMessage();
throw ex;
}
- ident.category = "";
- ident.name = token.value;
}
else
{
- StringHolder token = new StringHolder();
- if(!IceUtilInternal.StringUtil.unescapeString(s, 0, slash, token))
+ try
+ {
+ ident.category = IceUtilInternal.StringUtil.unescapeString(s, 0, slash);
+ }
+ catch(IllegalArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "invalid category in identity `" + s + "': " + e.getMessage();
throw ex;
}
- ident.category = token.value;
if(slash + 1 < s.length())
{
- if(!IceUtilInternal.StringUtil.unescapeString(s, slash + 1, s.length(), token))
+ try
+ {
+ ident.name = IceUtilInternal.StringUtil.unescapeString(s, slash + 1, s.length());
+ }
+ catch(IllegalArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
- ex.str = s;
+ ex.str = "invalid name in identity `" + s + "': " + e.getMessage();
throw ex;
}
- ident.name = token.value;
}
else
{
diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java
index 8946bf6f7b7..ce340c66e1b 100644
--- a/java/src/IceInternal/DefaultsAndOverrides.java
+++ b/java/src/IceInternal/DefaultsAndOverrides.java
@@ -108,7 +108,7 @@ public final class DefaultsAndOverrides
else
{
Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
- ex.str = value;
+ ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
throw ex;
}
diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java
index de816428863..50b5e8d2ac7 100644
--- a/java/src/IceInternal/EndpointFactoryManager.java
+++ b/java/src/IceInternal/EndpointFactoryManager.java
@@ -51,7 +51,7 @@ public final class EndpointFactoryManager
if(s.length() == 0)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = str;
+ e.str = "value has no non-whitespace characters";
throw e;
}
diff --git a/java/src/IceInternal/OpaqueEndpointI.java b/java/src/IceInternal/OpaqueEndpointI.java
index f4c9a8e1f3a..c85e27fedea 100644
--- a/java/src/IceInternal/OpaqueEndpointI.java
+++ b/java/src/IceInternal/OpaqueEndpointI.java
@@ -30,7 +30,8 @@ final class OpaqueEndpointI extends EndpointI
String option = arr[i++];
if(option.length() != 2 || option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("expected an endpoint option but found `" + option +
+ "' in endpoint `opaque " + str + "'");
}
String argument = null;
@@ -45,7 +46,8 @@ final class OpaqueEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("no argument provided for -t option in endpoint `opaque "
+ + str + "'");
}
int t;
@@ -55,16 +57,22 @@ final class OpaqueEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint `opaque " + str + "'");
}
if(t < 0 || t > 65535)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("timeout value `" + argument +
+ "' out of range in endpoint `opaque " + str + "'");
}
_type = (short)t;
++topt;
+ if(topt > 1)
+ {
+ throw new Ice.EndpointParseException("multiple -t options in endpoint `opaque " + str + "'");
+ }
break;
}
@@ -72,30 +80,42 @@ final class OpaqueEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("no argument provided for -v option in endpoint `opaque "
+ + str + "'");
}
for(int j = 0; j < argument.length(); ++j)
{
if(!IceUtilInternal.Base64.isBase64(argument.charAt(j)))
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("invalid base64 character `" + argument.charAt(j) +
+ "' (ordinal " + ((int)argument.charAt(j)) +
+ ") in endpoint `opaque " + str + "'");
}
}
_rawBytes = IceUtilInternal.Base64.decode(argument);
++vopt;
+ if(vopt > 1)
+ {
+ throw new Ice.EndpointParseException("multiple -v options in endpoint `opaque " + str + "'");
+ }
break;
}
default:
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("invalid option `" + option + "' in endpoint `opaque " +
+ str + "'");
}
}
}
- if(topt != 1 || vopt != 1)
+ if(topt != 1)
+ {
+ throw new Ice.EndpointParseException("no -t option in endpoint `opaque " + str + "'");
+ }
+ if(vopt != 1)
{
- throw new Ice.EndpointParseException("opaque " + str);
+ throw new Ice.EndpointParseException("no -v option in endpoint `opaque " + str + "'");
}
calcHashValue();
}
diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java
index 30a236394ec..574c121b1e0 100644
--- a/java/src/IceInternal/ReferenceFactory.java
+++ b/java/src/IceInternal/ReferenceFactory.java
@@ -83,7 +83,7 @@ public final class ReferenceFactory
if(beg == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "no non-whitespace characters found in `" + s + "'";
throw e;
}
@@ -96,7 +96,7 @@ public final class ReferenceFactory
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "mismatched quotes around identity in `" + s + "'";
throw e;
}
else if(end == 0)
@@ -118,7 +118,7 @@ public final class ReferenceFactory
if(beg == end)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "no identity in `" + s + "'";
throw e;
}
@@ -148,7 +148,7 @@ public final class ReferenceFactory
else if(IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "invalid characters after identity in `" + s + "'";
throw e;
}
else
@@ -190,7 +190,7 @@ public final class ReferenceFactory
if(option.length() != 2 || option.charAt(0) != '-')
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "expected a proxy option but found `" + option + "' in `" + s + "'";
throw e;
}
@@ -211,7 +211,7 @@ public final class ReferenceFactory
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "mismatched quotes around value for " + option + " option in `" + s + "'";
throw e;
}
else if(end == 0)
@@ -243,19 +243,21 @@ public final class ReferenceFactory
if(argument == null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "no argument provided for -f option in `" + s + "'";
throw e;
}
- Ice.StringHolder facetH = new Ice.StringHolder();
- if(!IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.length(), facetH))
+ try
+ {
+ facet = IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.length());
+ }
+ catch(IllegalArgumentException ex)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "invalid facet in `" + s + "': " + ex.getMessage();
throw e;
}
- facet = facetH.value;
break;
}
@@ -264,7 +266,7 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'";
throw e;
}
mode = Reference.ModeTwoway;
@@ -276,7 +278,7 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'";
throw e;
}
mode = Reference.ModeOneway;
@@ -288,7 +290,7 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'";
throw e;
}
mode = Reference.ModeBatchOneway;
@@ -300,7 +302,7 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'";
throw e;
}
mode = Reference.ModeDatagram;
@@ -312,7 +314,7 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'";
throw e;
}
mode = Reference.ModeBatchDatagram;
@@ -324,7 +326,7 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'";
throw e;
}
secure = true;
@@ -334,7 +336,7 @@ public final class ReferenceFactory
default:
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "unknown option `" + option + "' in `" + s + "'";
throw e;
}
}
@@ -412,8 +414,9 @@ public final class ReferenceFactory
}
if(endpoints.size() == 0)
{
+ assert(!unknownEndpoints.isEmpty());
Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = unknownEndpoints.get(0);
+ e.str = "invalid endpoint `" + unknownEndpoints.get(0) + "' in `" + s + "'";
throw e;
}
else if(unknownEndpoints.size() != 0 &&
@@ -439,7 +442,7 @@ public final class ReferenceFactory
if(beg == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "missing adapter id in `" + s + "'";
throw e;
}
@@ -448,7 +451,7 @@ public final class ReferenceFactory
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "mismatched quotes around adapter id in `" + s + "'";
throw e;
}
else if(end == 0)
@@ -470,24 +473,31 @@ public final class ReferenceFactory
if(end != s.length() && IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "invalid trailing characters after `" + s.substring(0, end + 1) + "' in `" + s + "'";
throw e;
}
-
- Ice.StringHolder token = new Ice.StringHolder();
- if(!IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.length(), token) ||
- token.value.length() == 0)
+
+ try
+ {
+ adapter = IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.length());
+ }
+ catch(IllegalArgumentException ex)
+ {
+ Ice.ProxyParseException e = new Ice.ProxyParseException();
+ e.str = "invalid adapter id in `" + s + "': " + ex.getMessage();
+ throw e;
+ }
+ if(adapter.length() == 0)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
+ e.str = "empty adapter id in `" + s + "'";
throw e;
}
- adapter = token.value;
return create(ident, facet, mode, secure, null, adapter, propertyPrefix);
}
Ice.ProxyParseException ex = new Ice.ProxyParseException();
- ex.str = s;
+ ex.str = "malformed proxy `" + s + "'";
throw ex;
}
@@ -782,7 +792,8 @@ public final class ReferenceFactory
}
else
{
- throw new Ice.EndpointSelectionTypeParseException(type);
+ throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type +
+ "'; expected `Random' or `Ordered'");
}
}
diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java
index 27618d8ccc5..f331068a9e8 100644
--- a/java/src/IceInternal/TcpEndpointI.java
+++ b/java/src/IceInternal/TcpEndpointI.java
@@ -46,7 +46,8 @@ final class TcpEndpointI extends EndpointI
String option = arr[i++];
if(option.length() != 2 || option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("expected an endpoint option but found `" + option +
+ "' in endpoint `tcp " + str + "'");
}
String argument = null;
@@ -65,7 +66,8 @@ final class TcpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -h option in endpoint `tcp "
+ + str + "'");
}
_host = argument;
@@ -76,7 +78,8 @@ final class TcpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -p option in endpoint `tcp "
+ + str + "'");
}
try
@@ -85,12 +88,14 @@ final class TcpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("invalid port value `" + argument +
+ "' in endpoint `tcp " + str + "'");
}
if(_port < 0 || _port > 65535)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("port value `" + argument +
+ "' out of range in endpoint `tcp " + str + "'");
}
break;
@@ -100,7 +105,8 @@ final class TcpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -t option in endpoint `tcp "
+ + str + "'");
}
try
@@ -109,7 +115,8 @@ final class TcpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint `tcp " + str + "'");
}
break;
@@ -119,7 +126,8 @@ final class TcpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("unexpected argument `" + argument +
+ "' provided for -z option in `tcp " + str + "'");
}
_compress = true;
@@ -128,7 +136,7 @@ final class TcpEndpointI extends EndpointI
default:
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("unknown option `" + option + "' in `tcp " + str + "'");
}
}
}
@@ -145,7 +153,7 @@ final class TcpEndpointI extends EndpointI
}
else
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `tcp " + str + "'");
}
}
diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java
index 880eae25473..153b9f99a96 100644
--- a/java/src/IceInternal/UdpEndpointI.java
+++ b/java/src/IceInternal/UdpEndpointI.java
@@ -57,7 +57,8 @@ final class UdpEndpointI extends EndpointI
String option = arr[i++];
if(option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("expected an endpoint option but found `" + option +
+ "' in endpoint `udp " + str + "'");
}
String argument = null;
@@ -74,13 +75,15 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -v option in endpoint `udp "
+ + str + "'");
}
int pos = argument.indexOf('.');
if(pos == -1)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("malformed protocol version `" + argument +
+ "' in endpoint `udp " + str + "'");
}
String majStr = argument.substring(0, pos);
@@ -94,12 +97,14 @@ final class UdpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("invalid protocol version `" + argument +
+ "' in endpoint `udp " + str + "'");
}
if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("range error in protocol version `" + argument +
+ "' in endpoint `udp " + str + "'");
}
if(majVersion != Protocol.protocolMajor)
@@ -119,13 +124,15 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -e option in endpoint `udp "
+ + str + "'");
}
int pos = argument.indexOf('.');
if(pos == -1)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("malformed encoding version `" + argument +
+ "' in endpoint `udp " + str + "'");
}
String majStr = argument.substring(0, pos);
@@ -139,12 +146,14 @@ final class UdpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("invalid encoding version `" + argument +
+ "' in endpoint `udp " + str + "'");
}
if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("range error in encoding version `" + argument +
+ "' in endpoint `udp " + str + "'");
}
if(majVersion != Protocol.encodingMajor)
@@ -164,7 +173,8 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -h option in endpoint `udp "
+ + str + "'");
}
_host = argument;
@@ -173,7 +183,8 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("no argument provided for -p option in endpoint `udp "
+ + str + "'");
}
try
@@ -182,19 +193,22 @@ final class UdpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("invalid port value `" + argument + "' in endpoint `udp " +
+ str + "'");
}
if(_port < 0 || _port > 65535)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("port value `" + argument +
+ "' out of range in endpoint `udp " + str + "'");
}
}
else if(option.equals("-c"))
{
if(argument != null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("unexpected argument `" + argument +
+ "' provided for -c option in `udp " + str + "'");
}
_connect = true;
@@ -204,7 +218,8 @@ final class UdpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("unexpected argument `" + argument +
+ "' provided for -z option in `udp " + str + "'");
}
_compress = true;
@@ -214,7 +229,8 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("no argument provided for --interface option in endpoint `udp "
+ + str + "'");
}
_mcastInterface = argument;
@@ -223,7 +239,8 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("no argument provided for --ttl option in endpoint `udp "
+ + str + "'");
}
try
@@ -232,17 +249,19 @@ final class UdpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("invalid TTL value `" + argument + "' in endpoint `udp " +
+ str + "'");
}
if(_mcastTtl < 0)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("TTL value `" + argument +
+ "' out of range in endpoint `udp " + str + "'");
}
}
else
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("unknown option `" + option + "' in `udp " + str + "'");
}
}
@@ -258,7 +277,7 @@ final class UdpEndpointI extends EndpointI
}
else
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'");
}
}
diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java
index 9c0282750da..97837176a0c 100644
--- a/java/src/IceSSL/EndpointI.java
+++ b/java/src/IceSSL/EndpointI.java
@@ -46,7 +46,8 @@ final class EndpointI extends IceInternal.EndpointI
String option = arr[i++];
if(option.length() != 2 || option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("expected an endpoint option but found `" + option +
+ "' in endpoint `ssl " + str + "'");
}
String argument = null;
@@ -65,7 +66,8 @@ final class EndpointI extends IceInternal.EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("no argument provided for -h option in endpoint `ssl "
+ + str + "'");
}
_host = argument;
@@ -76,7 +78,8 @@ final class EndpointI extends IceInternal.EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("no argument provided for -p option in endpoint `ssl "
+ + str + "'");
}
try
@@ -85,12 +88,14 @@ final class EndpointI extends IceInternal.EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("invalid port value `" + argument +
+ "' in endpoint `ssl " + str + "'");
}
if(_port < 0 || _port > 65535)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("port value `" + argument +
+ "' out of range in endpoint `ssl " + str + "'");
}
break;
@@ -100,7 +105,8 @@ final class EndpointI extends IceInternal.EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("no argument provided for -t option in endpoint `ssl "
+ + str + "'");
}
try
@@ -109,7 +115,8 @@ final class EndpointI extends IceInternal.EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint `ssl " + str + "'");
}
break;
@@ -119,7 +126,8 @@ final class EndpointI extends IceInternal.EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("unexpected argument `" + argument +
+ "' provided for -z option in `ssl " + str + "'");
}
_compress = true;
@@ -128,7 +136,7 @@ final class EndpointI extends IceInternal.EndpointI
default:
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("unknown option `" + option + "' in `ssl " + str + "'");
}
}
}
@@ -145,7 +153,7 @@ final class EndpointI extends IceInternal.EndpointI
}
else
{
- throw new Ice.EndpointParseException("ssl " + str);
+ throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `ssl " + str + "'");
}
}
diff --git a/java/src/IceUtilInternal/StringUtil.java b/java/src/IceUtilInternal/StringUtil.java
index befc624f425..137bb234e06 100644
--- a/java/src/IceUtilInternal/StringUtil.java
+++ b/java/src/IceUtilInternal/StringUtil.java
@@ -199,11 +199,22 @@ public final class StringUtil
}
private static char
- checkChar(char c)
+ checkChar(String s, int pos)
{
+ char c = s.charAt(pos);
if(!(c >= 32 && c <= 126))
{
- throw new IllegalArgumentException("illegal input character");
+ String msg;
+ if(pos > 0)
+ {
+ msg = "character after `" + s.substring(0, pos) + "'";
+ }
+ else
+ {
+ msg = "first character";
+ }
+ msg += " is not a printable ASCII character (ordinal " + (int)c + ")";
+ throw new IllegalArgumentException(msg);
}
return c;
}
@@ -223,13 +234,13 @@ public final class StringUtil
if(s.charAt(start) != '\\')
{
- c = checkChar(s.charAt(start++));
+ c = checkChar(s, start++);
}
else
{
if(start + 1 == end)
{
- throw new IllegalArgumentException("trailing backslash in argument");
+ throw new IllegalArgumentException("trailing backslash");
}
switch(s.charAt(++start))
{
@@ -279,7 +290,7 @@ public final class StringUtil
case '6':
case '7':
{
- int oct = 0;
+ int val = 0;
for(int j = 0; j < 3 && start < end; ++j)
{
int charVal = s.charAt(start++) - '0';
@@ -288,18 +299,19 @@ public final class StringUtil
--start;
break;
}
- oct = oct * 8 + charVal;
+ val = val * 8 + charVal;
}
- if(oct > 255)
+ if(val > 255)
{
- throw new IllegalArgumentException("octal value out of range");
+ String msg = "octal value \\" + Integer.toOctalString(val) + " (" + val + ") is out of range";
+ throw new IllegalArgumentException(msg);
}
- c = (char)oct;
+ c = (char)val;
break;
}
default:
{
- c = checkChar(s.charAt(start++));
+ c = checkChar(s, start++);
break;
}
}
@@ -324,42 +336,33 @@ public final class StringUtil
}
//
- // Remove escape sequences added by escapeString.
+ // Remove escape sequences added by escapeString. Throws IllegalArgumentException
+ // for an invalid input string.
//
- public static boolean
- unescapeString(String s, int start, int end, Ice.StringHolder result)
+ public static String
+ unescapeString(String s, int start, int end)
{
- if(start < 0)
- {
- throw new IllegalArgumentException("start offset must be >= 0");
- }
- if(end > s.length())
- {
- throw new IllegalArgumentException("end offset must <= s.length()");
- }
- if(start > end)
+ assert(start >= 0 && start <= end && end <= s.length());
+
+ StringBuilder sb = new StringBuilder(end - start);
+ decodeString(s, start, end, sb);
+ String decodedString = sb.toString();
+
+ byte[] arr = new byte[decodedString.length()];
+ for(int i = 0; i < arr.length; ++i)
{
- throw new IllegalArgumentException("start offset must <= end offset");
+ arr[i] = (byte)decodedString.charAt(i);
}
try
{
- StringBuilder sb = new StringBuilder(end - start);
- decodeString(s, start, end, sb);
- String decodedString = sb.toString();
-
- byte[] arr = new byte[decodedString.length()];
- for(int i = 0; i < arr.length; ++i)
- {
- arr[i] = (byte)decodedString.charAt(i);
- }
-
- result.value = new String(arr, 0, arr.length, "UTF8");
- return true;
+ return new String(arr, 0, arr.length, "UTF8");
}
- catch(java.lang.Exception ex)
+ catch(java.io.UnsupportedEncodingException ex)
{
- return false;
+ IllegalArgumentException e = new IllegalArgumentException("unsupported encoding");
+ e.initCause(ex);
+ throw e;
}
}
diff --git a/java/test/Ice/proxy/AllTests.java b/java/test/Ice/proxy/AllTests.java
index 39d772b08e9..678a0b9cf52 100644
--- a/java/test/Ice/proxy/AllTests.java
+++ b/java/test/Ice/proxy/AllTests.java
@@ -99,12 +99,34 @@ public class AllTests
test(b1.ice_getIdentity().name.equals("test\1114test"));
b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test");
- test(b1.ice_getIdentity().name.equals("test\b\f\n\r\t\'\"\\test") && b1.ice_getIdentity().category.length() == 0);
+ test(b1.ice_getIdentity().name.equals("test\b\f\n\r\t\'\"\\test") &&
+ b1.ice_getIdentity().category.length() == 0);
b1 = communicator.stringToProxy("category/test");
test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category") &&
b1.ice_getAdapterId().length() == 0);
-
+
+ b1 = communicator.stringToProxy("");
+ test(b1 == null);
+ b1 = communicator.stringToProxy("\"\"");
+ test(b1 == null);
+ try
+ {
+ b1 = communicator.stringToProxy("\"\" test"); // Invalid trailing characters.
+ test(false);
+ }
+ catch(Ice.ProxyParseException ex)
+ {
+ }
+ try
+ {
+ b1 = communicator.stringToProxy("test:"); // Missing endpoint.
+ test(false);
+ }
+ catch(Ice.EndpointParseException ex)
+ {
+ }
+
b1 = communicator.stringToProxy("test@adapter");
test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 &&
b1.ice_getAdapterId().equals("adapter"));
@@ -637,7 +659,7 @@ public class AllTests
Ice.ObjectPrx p1 = communicator.stringToProxy("test:opaque -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==");
String pstr = communicator.proxyToString(p1);
test(pstr.equals("test -t:tcp -h 127.0.0.1 -p 12010 -t 10000"));
-
+
// Working?
boolean ssl = communicator.getProperties().getProperty("Ice.Default.Protocol").equals("ssl");
if(!ssl)
diff --git a/slice/Ice/Communicator.ice b/slice/Ice/Communicator.ice
index 1641adf4815..16fce736278 100644
--- a/slice/Ice/Communicator.ice
+++ b/slice/Ice/Communicator.ice
@@ -124,7 +124,8 @@ local interface Communicator
* having an identity with a name "MyObject" and a category
* "MyCategory", with the server running on host "some_host", port
* 10000. If the string does not parse correctly, the operation
- * throws {@link ProxyParseException}.
+ * throws one of {@link ProxyParseException},
+ * {@link EndpointParseException}, or {@link IdentityParseException}.
*
* @param str The string to convert into a proxy.
*
@@ -175,7 +176,8 @@ local interface Communicator
/**
*
- * Convert a string into an identity.
+ * Convert a string into an identity. If the string does not parse
+ * correctly, the operation throws {@link IdentityParseException}.
*
* @param str The string to convert into an identity.
*