From 046377be221aaf8c3715c3b7e9443f7ef96d5ee9 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 20 Feb 2024 09:14:45 -0500 Subject: [PATCH] Implement #1813 for C++ (#1814) --- cpp/include/Ice/LocalException.h | 21 ++---------- cpp/src/Ice/CheckIdentity.h | 21 ++++++++++++ cpp/src/Ice/ConnectionI.cpp | 16 +++------- cpp/src/Ice/Exception.cpp | 2 +- cpp/src/Ice/Initialize.cpp | 3 ++ cpp/src/Ice/InputStream.cpp | 9 +++++- cpp/src/Ice/Instance.cpp | 6 ++-- cpp/src/Ice/ObjectAdapterI.cpp | 24 ++++++-------- cpp/src/Ice/Proxy.cpp | 6 ++-- cpp/src/Ice/ReferenceFactory.cpp | 32 ++++++------------- cpp/test/Ice/exceptions/AllTests.cpp | 1 - cpp/test/Ice/proxy/AllTests.cpp | 10 ++++++ js/src/Ice/LocalException.d.ts | 9 +----- js/src/Ice/LocalException.js | 3 +- js/src/Ice/ObjectAdapterI.js | 2 +- js/src/Ice/Reference.js | 2 +- js/test/Ice/exceptions/Client.js | 1 - js/test/typescript/Ice/exceptions/Client.ts | 1 - php/lib/IceLocal/LocalException.php | 7 +--- php/src/Util.cpp | 11 ------- python/modules/IcePy/Util.cpp | 5 --- python/python/Ice/LocalException_local.py | 13 +++----- python/test/Ice/exceptions/AllTests.py | 6 ++-- ruby/ruby/IceLocal/LocalException.rb | 7 ++-- ruby/src/IceRuby/Util.cpp | 5 --- swift/src/Ice/LocalException.swift | 14 +------- swift/src/Ice/LocalExceptionDescription.swift | 4 +-- swift/src/Ice/LocalExceptionFactory.swift | 4 +-- swift/src/IceImpl/Convert.mm | 2 +- swift/src/IceImpl/Exception.h | 2 +- 30 files changed, 93 insertions(+), 156 deletions(-) create mode 100644 cpp/src/Ice/CheckIdentity.h diff --git a/cpp/include/Ice/LocalException.h b/cpp/include/Ice/LocalException.h index 2dab1433325..5bda1e9b550 100644 --- a/cpp/include/Ice/LocalException.h +++ b/cpp/include/Ice/LocalException.h @@ -1196,25 +1196,13 @@ class ICE_CLASS(ICE_API) IllegalIdentityException : public LocalExceptionHelper< { } - /** - * One-shot constructor to initialize all data members. - * The file and line number are required for all local exceptions. - * @param file The file name in which the exception was raised, typically __FILE__. - * @param line The line number at which the exception was raised, typically __LINE__. - * @param id The illegal identity. - */ - IllegalIdentityException(const char* file, int line, const Identity& id) : LocalExceptionHelper(file, line), - id(id) - { - } - /** * Obtains a tuple containing all of the exception's data members. * @return The data members in a tuple. */ - std::tuple ice_tuple() const + std::tuple<> ice_tuple() const { - return std::tie(id); + return std::tie(); } /** @@ -1227,11 +1215,6 @@ class ICE_CLASS(ICE_API) IllegalIdentityException : public LocalExceptionHelper< * @param stream The target stream. */ ICE_MEMBER(ICE_API) virtual void ice_print(::std::ostream& stream) const override; - - /** - * The illegal identity. - */ - ::Ice::Identity id; }; /** diff --git a/cpp/src/Ice/CheckIdentity.h b/cpp/src/Ice/CheckIdentity.h new file mode 100644 index 00000000000..9355b8a3823 --- /dev/null +++ b/cpp/src/Ice/CheckIdentity.h @@ -0,0 +1,21 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "Ice/Identity.h" +#include "Ice/LocalException.h" + +namespace Ice +{ + +// An identity with an empty name is illegal for all Ice APIs: no Ice API returns such an identity, and no Ice API +// accepts such an identity argument. +inline void checkIdentity(const Identity& identity, const char* file, int line) +{ + if (identity.name.empty()) + { + throw IllegalIdentityException(file, line); + } +} + +} diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index b45b65914ea..e62e1e8d409 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -22,6 +22,7 @@ #include // For createProxy(). #include // For createProxy(). #include +#include "CheckIdentity.h" #ifdef ICE_HAS_BZIP2 # include @@ -1282,18 +1283,9 @@ Ice::ConnectionI::getEndpoint() const noexcept optional Ice::ConnectionI::createProxy(const Identity& ident) const { - // Create a reference and return a reverse proxy for this reference. - ReferencePtr ref = - _instance->referenceFactory()->create(ident, const_cast(this)->shared_from_this()); - - if (ref) - { - return ObjectPrx::_fromReference(std::move(ref)); - } - else - { - return std::nullopt; - } + checkIdentity(ident, __FILE__, __LINE__); + return ObjectPrx::_fromReference( + _instance->referenceFactory()->create(ident, const_cast(this)->shared_from_this())); } void diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 17da6c49fa4..d25ec1cf15f 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -306,7 +306,7 @@ void Ice::IllegalIdentityException::ice_print(ostream& out) const { Exception::ice_print(out); - out << ":\nillegal identity: `" << identityToString(id, ToStringMode::Unicode) << "'"; + out << ":\nan identity with an empty name is not allowed"; } void diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index a53d7f94190..e72088398be 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "CheckIdentity.h" #include @@ -515,12 +516,14 @@ Ice::stringToIdentity(const string& s) } } + checkIdentity(ident, __FILE__, __LINE__); return ident; } string Ice::identityToString(const Identity& ident, ToStringMode toStringMode) { + checkIdentity(ident, __FILE__, __LINE__); if(ident.category.empty()) { return escapeString(ident.name, "/", toStringMode); diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index 07e9165e636..7860144b615 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -1176,7 +1176,14 @@ Ice::InputStream::readReference() Identity ident; read(ident); - return _instance->referenceFactory()->create(ident, this); + if (ident.name.empty()) + { + return nullptr; + } + else + { + return _instance->referenceFactory()->create(ident, this); + } } Int diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index e9eb10b9338..6421c135f99 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -44,6 +44,7 @@ #include #include "Ice/ProxyFunctions.h" +#include "CheckIdentity.h" #include #include @@ -558,10 +559,7 @@ IceInternal::Instance::createAdmin(const ObjectAdapterPtr& adminAdapter, const I throw CommunicatorDestroyedException(__FILE__, __LINE__); } - if(adminIdentity.name.empty()) - { - throw Ice::IllegalIdentityException(__FILE__, __LINE__, adminIdentity); - } + checkIdentity(adminIdentity, __FILE__, __LINE__); if(_adminAdapter) { diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index b473ec84f1e..fba7c835032 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -28,6 +28,7 @@ #include #include #include "Ice/ProxyFunctions.h" +#include "CheckIdentity.h" #ifdef _WIN32 # include @@ -43,13 +44,6 @@ using namespace IceInternal; namespace { -inline void checkIdentity(const Identity& ident) -{ - if(ident.name.empty()) - { - throw IllegalIdentityException(__FILE__, __LINE__, ident); - } -} inline void checkServant(const shared_ptr& servant) { @@ -381,7 +375,7 @@ Ice::ObjectAdapterI::addFacet(const shared_ptr& object, const Identity& checkForDeactivation(); checkServant(object); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); _servantManager->addServant(object, ident, facet); @@ -425,7 +419,7 @@ Ice::ObjectAdapterI::removeFacet(const Identity& ident, const string& facet) lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return _servantManager->removeServant(ident, facet); } @@ -436,7 +430,7 @@ Ice::ObjectAdapterI::removeAllFacets(const Identity& ident) lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return _servantManager->removeAllFacets(ident); } @@ -463,7 +457,7 @@ Ice::ObjectAdapterI::findFacet(const Identity& ident, const string& facet) const lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return _servantManager->findServant(ident, facet); } @@ -474,7 +468,7 @@ Ice::ObjectAdapterI::findAllFacets(const Identity& ident) const lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return _servantManager->findAllFacets(ident); } @@ -536,7 +530,7 @@ Ice::ObjectAdapterI::createProxy(const Identity& ident) const lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return newProxy(ident, ""); } @@ -547,7 +541,7 @@ Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) const lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return newDirectProxy(ident, ""); } @@ -558,7 +552,7 @@ Ice::ObjectAdapterI::createIndirectProxy(const Identity& ident) const lock_guard lock(_mutex); checkForDeactivation(); - checkIdentity(ident); + checkIdentity(ident, __FILE__, __LINE__); return newIndirectProxy(ident, "", _id); } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 4de4f0dd667..f2adeef03d0 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -13,6 +13,7 @@ #include "ReferenceFactory.h" #include "RequestHandlerCache.h" #include "ConnectionI.h" +#include "CheckIdentity.h" using namespace std; using namespace Ice; @@ -80,10 +81,7 @@ Ice::ObjectPrx::ice_getIdentity() const ObjectPrx Ice::ObjectPrx::ice_identity(const Identity& newIdentity) const { - if (newIdentity.name.empty()) - { - throw IllegalIdentityException(__FILE__, __LINE__); - } + checkIdentity(newIdentity, __FILE__, __LINE__); if (newIdentity == _reference->getIdentity()) { return *this; diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 42d6b1d57aa..4a13c8eeff8 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -87,7 +87,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP { if(str.empty()) { - return 0; + return nullptr; } const string delim = " \t\r\n"; @@ -133,37 +133,29 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP throw ProxyParseException(__FILE__, __LINE__, "no identity in `" + s + "'"); } - // - // Parsing the identity may raise IdentityParseException. - // - Identity ident = Ice::stringToIdentity(idstr); - - if(ident.name.empty()) + if (idstr.empty()) { - // - // An identity with an empty name and a non-empty - // category is illegal. - // - if(!ident.category.empty()) - { - throw IllegalIdentityException(__FILE__, __LINE__, ident); - } // // Treat a stringified proxy containing two double // quotes ("") the same as an empty string, i.e., // a null proxy, but only if nothing follows the // quotes. // - else if(s.find_first_not_of(delim, end) != string::npos) + if(s.find_first_not_of(delim, end) != string::npos) { throw ProxyParseException(__FILE__, __LINE__, "invalid characters after identity in `" + s + "'"); } else { - return 0; + return nullptr; } } + // + // Parsing the identity may raise IdentityParseException. + // + Identity ident = Ice::stringToIdentity(idstr); + string facet; Reference::Mode mode = Reference::ModeTwoway; bool secure = false; @@ -533,11 +525,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, InputStream* s) // Don't read the identity here. Operations calling this // constructor read the identity, and pass it as a parameter. // - - if(ident.name.empty() && ident.category.empty()) - { - return 0; - } + assert(!ident.name.empty()); // // For compatibility with the old FacetPath. diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index 1f5da250ebe..88d20bfc344 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -210,7 +210,6 @@ allTests(Test::TestHelper* helper) } catch(const Ice::IllegalIdentityException& ex) { - test(ex.id.name == ""); if(printException) { Ice::Print printer(communicator->getLogger()); diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 70978bc13eb..b91f56eb3a2 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -318,6 +318,16 @@ allTests(Test::TestHelper* helper) id2 = Ice::stringToIdentity(idStr); test(id == id2); + try + { + // Ice APIs can't return all illegal identity. + id = Ice::stringToIdentity(""); + assert(false); + } + catch (const Ice::IllegalIdentityException&) + { + } + // Input string with various pitfalls id = Ice::stringToIdentity("\\342\\x82\\254\\60\\x9\\60\\"); test(id.name == "\xE2\x82\xAC\60\t0\\" && id.category.empty()); diff --git a/js/src/Ice/LocalException.d.ts b/js/src/Ice/LocalException.d.ts index afb5b456df0..7cf9dcf428a 100644 --- a/js/src/Ice/LocalException.d.ts +++ b/js/src/Ice/LocalException.d.ts @@ -297,17 +297,10 @@ export namespace Ice } /** - * This exception is raised if an illegal identity is encountered. + * This exception is raised if an identity with an empty name is encountered. */ class IllegalIdentityException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param id The illegal identity. - * @param ice_cause The error that cause this exception. - */ - constructor(id?:Identity, ice_cause?:string|Error); - id:Identity; } /** diff --git a/js/src/Ice/LocalException.js b/js/src/Ice/LocalException.js index 9d4e3a84a8c..62e9f6d1021 100644 --- a/js/src/Ice/LocalException.js +++ b/js/src/Ice/LocalException.js @@ -499,10 +499,9 @@ Ice.ProxyParseException = class extends Ice.LocalException **/ Ice.IllegalIdentityException = class extends Ice.LocalException { - constructor(id = new Ice.Identity(), _cause = "") + constructor(_cause = "") { super(_cause); - this.id = id; } static get _parent() diff --git a/js/src/Ice/ObjectAdapterI.js b/js/src/Ice/ObjectAdapterI.js index dfe17fc788a..40bf5aeff28 100644 --- a/js/src/Ice/ObjectAdapterI.js +++ b/js/src/Ice/ObjectAdapterI.js @@ -521,7 +521,7 @@ class ObjectAdapterI { if(ident.name === undefined || ident.name === null || ident.name.length === 0) { - throw new Ice.IllegalIdentityException(ident); + throw new Ice.IllegalIdentityException(); } if(ident.category === undefined || ident.category === null) diff --git a/js/src/Ice/Reference.js b/js/src/Ice/Reference.js index 81c8b832b61..fb24a3a67ca 100644 --- a/js/src/Ice/Reference.js +++ b/js/src/Ice/Reference.js @@ -181,7 +181,7 @@ class ReferenceFactory // if(ident.category.length > 0) { - throw new Ice.IllegalIdentityException(ident); + throw new Ice.IllegalIdentityException(); } // // Treat a stringified proxy containing two double diff --git a/js/test/Ice/exceptions/Client.js b/js/test/Ice/exceptions/Client.js index 2348375af50..f28bebb8ef1 100644 --- a/js/test/Ice/exceptions/Client.js +++ b/js/test/Ice/exceptions/Client.js @@ -79,7 +79,6 @@ catch(ex) { test(ex instanceof Ice.IllegalIdentityException, ex); - test(ex.id.name === ""); } try diff --git a/js/test/typescript/Ice/exceptions/Client.ts b/js/test/typescript/Ice/exceptions/Client.ts index 8fcb2b2e1cb..9eb9a82022a 100644 --- a/js/test/typescript/Ice/exceptions/Client.ts +++ b/js/test/typescript/Ice/exceptions/Client.ts @@ -77,7 +77,6 @@ export class Client extends TestHelper catch(ex) { test(ex instanceof Ice.IllegalIdentityException, ex); - test(ex.id.name === ""); } try diff --git a/php/lib/IceLocal/LocalException.php b/php/lib/IceLocal/LocalException.php index a0e7ec416a7..42da01fd51c 100644 --- a/php/lib/IceLocal/LocalException.php +++ b/php/lib/IceLocal/LocalException.php @@ -586,7 +586,6 @@ class IllegalIdentityException extends \Ice\LocalException { public function __construct($id=null) { - $this->id = is_null($id) ? new \Ice\Identity : $id; } public function ice_id() @@ -599,13 +598,9 @@ public function __toString(): string global $Ice__t_IllegalIdentityException; return IcePHP_stringifyException($this, $Ice__t_IllegalIdentityException); } - - public $id; } - global $Ice__t_Identity; - $Ice__t_IllegalIdentityException = IcePHP_defineException('::Ice::IllegalIdentityException', '\\Ice\\IllegalIdentityException', false, null, array( - array('id', $Ice__t_Identity, false, 0))); + $Ice__t_IllegalIdentityException = IcePHP_defineException('::Ice::IllegalIdentityException', '\\Ice\\IllegalIdentityException', false, null, null); } namespace Ice diff --git a/php/src/Util.cpp b/php/src/Util.cpp index 71fe550e616..4fa5c90777c 100644 --- a/php/src/Util.cpp +++ b/php/src/Util.cpp @@ -462,17 +462,6 @@ convertLocalException(const Ice::LocalException& ex, zval* zex) { setStringMember(zex, "str", e.str); } - catch(const Ice::IllegalIdentityException& e) - { - zval id; - if(!createIdentity(&id, e.id)) - { - zval_ptr_dtor(&id); - return false; - } - zendUpdateProperty(cls, zex, const_cast("id"), sizeof("id") - 1, &id); - zval_ptr_dtor(&id); - } catch(const Ice::RequestFailedException& e) { zval id; diff --git a/python/modules/IcePy/Util.cpp b/python/modules/IcePy/Util.cpp index 50a8d737eaf..e9ee7296ae7 100644 --- a/python/modules/IcePy/Util.cpp +++ b/python/modules/IcePy/Util.cpp @@ -819,11 +819,6 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) IcePy::PyObjectHandle m = IcePy::createString(e.str); PyObject_SetAttrString(p, STRCAST("str"), m.get()); } - catch(const Ice::IllegalIdentityException& e) - { - IcePy::PyObjectHandle m = IcePy::createIdentity(e.id); - PyObject_SetAttrString(p, STRCAST("id"), m.get()); - } catch(const Ice::IllegalServantException& e) { IcePy::PyObjectHandle m = IcePy::createString(e.reason); diff --git a/python/python/Ice/LocalException_local.py b/python/python/Ice/LocalException_local.py index 51bc6ed0a11..abdcfca7093 100644 --- a/python/python/Ice/LocalException_local.py +++ b/python/python/Ice/LocalException_local.py @@ -714,16 +714,11 @@ def __str__(self): class IllegalIdentityException(Ice.LocalException): """ - This exception is raised if an illegal identity is encountered. - Members: - id -- The illegal identity. + This exception is raised if an identity with an empty name is encountered. """ - def __init__(self, id=Ice._struct_marker): - if id is Ice._struct_marker: - self.id = _M_Ice.Identity() - else: - self.id = id + def __init__(self): + pass def __str__(self): return IcePy.stringifyException(self) @@ -738,7 +733,7 @@ def __str__(self): (), False, None, - (("id", (), _M_Ice._t_Identity, False, 0),), + (), ) IllegalIdentityException._ice_type = _M_Ice._t_IllegalIdentityException diff --git a/python/test/Ice/exceptions/AllTests.py b/python/test/Ice/exceptions/AllTests.py index 7173dbf32db..50429c02b40 100644 --- a/python/test/Ice/exceptions/AllTests.py +++ b/python/test/Ice/exceptions/AllTests.py @@ -232,10 +232,10 @@ def allTests(helper, communicator): pass try: - adapter.add(obj, Ice.stringToIdentity("")) + adapter.add(obj, Ice.Identity("", "")) test(False) - except Ice.IllegalIdentityException as ex: - test(ex.id.name == "") + except Ice.IllegalIdentityException: + pass try: adapter.add(None, Ice.stringToIdentity("x")) diff --git a/ruby/ruby/IceLocal/LocalException.rb b/ruby/ruby/IceLocal/LocalException.rb index 8369055a938..cf793d74c73 100644 --- a/ruby/ruby/IceLocal/LocalException.rb +++ b/ruby/ruby/IceLocal/LocalException.rb @@ -335,18 +335,15 @@ def to_s if not defined?(::Ice::IllegalIdentityException) class IllegalIdentityException < Ice::LocalException - def initialize(id=::Ice::Identity.new) - @id = id + def initialize end def to_s '::Ice::IllegalIdentityException' end - - attr_accessor :id end - T_IllegalIdentityException = ::Ice::__defineException('::Ice::IllegalIdentityException', IllegalIdentityException, false, nil, [["id", ::Ice::T_Identity, false, 0]]) + T_IllegalIdentityException = ::Ice::__defineException('::Ice::IllegalIdentityException', IllegalIdentityException, false, nil, []) end if not defined?(::Ice::IllegalServantException) diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp index 0618ddd7c2f..008a7f2d11d 100644 --- a/ruby/src/IceRuby/Util.cpp +++ b/ruby/src/IceRuby/Util.cpp @@ -663,11 +663,6 @@ setExceptionMembers(const Ice::LocalException& ex, VALUE p) volatile VALUE v = createString(e.str); callRuby(rb_iv_set, p, "@str", v); } - catch(const Ice::IllegalIdentityException& e) - { - volatile VALUE v = IceRuby::createIdentity(e.id); - callRuby(rb_iv_set, p, "@id", v); - } catch(const Ice::IllegalServantException& e) { volatile VALUE v = createString(e.reason); diff --git a/swift/src/Ice/LocalException.swift b/swift/src/Ice/LocalException.swift index 0fbb19bee6d..4f18fd540dc 100644 --- a/swift/src/Ice/LocalException.swift +++ b/swift/src/Ice/LocalException.swift @@ -556,20 +556,8 @@ open class ProxyParseException: LocalException { } } -/// This exception is raised if an illegal identity is encountered. +/// This exception is raised if an identity with an empty name is encountered. open class IllegalIdentityException: LocalException { - /// The illegal identity. - public var id: Identity = .init() - - public required init() { - super.init() - } - - public init(id: Identity, file: Swift.String = #file, line: Swift.Int = #line) { - self.id = id - super.init(file: file, line: line) - } - /// Returns the Slice type ID of this exception. /// /// - returns: `Swift.String` - the Slice type ID of this exception. diff --git a/swift/src/Ice/LocalExceptionDescription.swift b/swift/src/Ice/LocalExceptionDescription.swift index ce0f63a5de5..98347838e20 100644 --- a/swift/src/Ice/LocalExceptionDescription.swift +++ b/swift/src/Ice/LocalExceptionDescription.swift @@ -247,8 +247,8 @@ extension ProxyParseException { extension IllegalIdentityException { var _IllegalIdentityExceptionDescription: String { var s = String() - let identity: String = identityToString(id: id, mode: .Unicode) - s.sep("llegal identity: `\(identity)'") + + s.sep("an identity with an empty name is not allowed") return s } diff --git a/swift/src/Ice/LocalExceptionFactory.swift b/swift/src/Ice/LocalExceptionFactory.swift index 9c3ae6db11b..5cfc9493258 100644 --- a/swift/src/Ice/LocalExceptionFactory.swift +++ b/swift/src/Ice/LocalExceptionFactory.swift @@ -73,8 +73,8 @@ class ExceptionFactory: ICEExceptionFactory { return ProxyParseException(str: str, file: file, line: line) } - static func illegalIdentityException(_ name: String, category: String, file: String, line: Int) -> Error { - return IllegalIdentityException(id: Identity(name: name, category: category), file: file, line: line) + static func illegalIdentityException(_ file: String, line: Int) -> Error { + return IllegalIdentityException(file: file, line: line) } static func illegalServantException(_ reason: String, file: String, line: Int) -> Error { diff --git a/swift/src/IceImpl/Convert.mm b/swift/src/IceImpl/Convert.mm index 4d74369c06a..372b56dabb3 100644 --- a/swift/src/IceImpl/Convert.mm +++ b/swift/src/IceImpl/Convert.mm @@ -104,7 +104,7 @@ } catch(const Ice::IllegalIdentityException& e) { - return [factory illegalIdentityException:toNSString(e.id.name) category:toNSString(e.id.category) file:toNSString(e.ice_file()) line:e.ice_line()]; + return [factory illegalIdentityException:toNSString(e.ice_file()) line:e.ice_line()]; } catch(const Ice::IllegalServantException& e) { diff --git a/swift/src/IceImpl/Exception.h b/swift/src/IceImpl/Exception.h index 9df62767dec..702bd1f3a02 100644 --- a/swift/src/IceImpl/Exception.h +++ b/swift/src/IceImpl/Exception.h @@ -25,7 +25,7 @@ ICEIMPL_API @protocol ICEExceptionFactory +(NSError*) versionParseException:(NSString*)str file:(NSString*)file line:(size_t)line; +(NSError*) identityParseException:(NSString*)str file:(NSString*)file line:(size_t)line; +(NSError*) proxyParseException:(NSString*)str file:(NSString*)file line:(size_t)line; -+(NSError*) illegalIdentityException:(NSString*)name category:(NSString*)category file:(NSString*)file line:(size_t)line; ++(NSError*) illegalIdentityException:(NSString*)file line:(size_t)line; +(NSError*) illegalServantException:(NSString*)reason file:(NSString*)file line:(size_t)line; +(NSError*) dNSException:(int32_t)error host:(NSString*)host file:(NSString*)file line:(size_t)line; +(NSError*) operationInterruptedException:(NSString*)file line:(size_t)line;