From feaa7da2cfcf709f20ca06f72896d860cc62791d Mon Sep 17 00:00:00 2001 From: Joe George Date: Tue, 22 Oct 2024 14:28:16 -0400 Subject: [PATCH 01/10] wip --- config/PropertyNames.xml | 34 ++-- config/makeprops.py | 41 ++-- cpp/include/Ice/LocalExceptions.h | 5 +- cpp/src/Ice/LocalExceptions.cpp | 4 +- cpp/src/Ice/MetricsAdminI.cpp | 2 +- cpp/src/Ice/Properties.cpp | 12 +- cpp/src/Ice/PropertyNames.cpp | 192 +++++++++--------- cpp/src/Ice/PropertyNames.h | 4 +- cpp/src/Ice/PropertyUtil.cpp | 2 +- cpp/test/Ice/properties/Client.cpp | 8 +- csharp/src/Ice/Internal/PropertyNames.cs | 13 -- .../java/com/zeroc/Ice/ObjectAdapter.java | 7 +- .../java/com/zeroc/Ice/PropertyNames.java | 13 -- js/src/Ice/PropertyNames.js | 4 - 14 files changed, 166 insertions(+), 175 deletions(-) diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 3c86deb2a53..a5f9c26514e 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -67,7 +67,7 @@ --> -
+
@@ -162,16 +162,16 @@
-
+ -
+
@@ -186,7 +186,7 @@
-
+
@@ -200,7 +200,7 @@
-
+
@@ -209,17 +209,17 @@
-
+
-
+
-
+
@@ -238,7 +238,7 @@
-
+
@@ -301,7 +301,7 @@
-
+
@@ -333,7 +333,7 @@
-
+
@@ -360,18 +360,18 @@
-
+
-
+
-
+
@@ -398,12 +398,12 @@
-
+
- + diff --git a/config/makeprops.py b/config/makeprops.py index cca349cccff..3bec300102c 100755 --- a/config/makeprops.py +++ b/config/makeprops.py @@ -35,9 +35,10 @@ class Language(StrEnum): class PropertyArray: - def __init__(self, name: str, prefixOnly: bool, isClass: bool): + def __init__(self, name: str, prefixOnly: bool, isClass: bool, enabled: bool): self.name = name self.prefixOnly = prefixOnly + self.enabled = False self.isClass = isClass self.properties = [] @@ -180,17 +181,29 @@ def startElement(self, name, attrs): case "properties": pass case "class": - self.validateKnownAttributes(["name", "prefix-only"], attrs) - self.parentNodeName = f"{attrs.get("name")}" + name = f"{attrs.get("name")}" prefixOnly = attrs.get("prefix-only", "false").lower() == "true" - self.propertyArrayDict[self.parentNodeName] = PropertyArray( - self.parentNodeName, prefixOnly, True + enabled = attrs.get("enabled", "true").lower() == "true" + + self.validateKnownAttributes(["name", "prefix-only"], attrs) + self.parentNodeName = name + self.propertyArrayDict[name] = PropertyArray( + name=name, + prefixOnly=prefixOnly, + isClass=True, + enabled=enabled, ) case "section": - self.validateKnownAttributes(["name"], attrs) - self.parentNodeName = attrs.get("name") + enabled = attrs.get("enabled", "true").lower() == "true" + name = attrs.get("name") + + self.validateKnownAttributes(["name", "enabled"], attrs) + self.parentNodeName = name self.propertyArrayDict[self.parentNodeName] = PropertyArray( - self.parentNodeName, False, False + name=name, + prefixOnly=False, + isClass=False, + enabled=enabled, ) case "property": @@ -263,6 +276,7 @@ def openFiles(self): const bool prefixOnly; const Property* properties; const int length; + const bool enabled; }}; class PropertyNames @@ -304,7 +318,7 @@ def fix(self, propertyName): def writePropertyArray(self, propertyArray): name = propertyArray.name prefixOnly = "true" if propertyArray.prefixOnly else "false" - + enabled = "true" if propertyArray.enabled else "false" self.hFile.write(f" static const PropertyArray {name}Props;\n") self.cppFile.write(f"""\ @@ -315,10 +329,11 @@ def writePropertyArray(self, propertyArray): const PropertyArray PropertyNames::{name}Props {{ - "{name}", - {prefixOnly}, - {name}PropsData, - {len(propertyArray.properties)} + .name="{name}", + .prefixOnly={prefixOnly}, + .properties={name}PropsData, + .length={len(propertyArray.properties)}, + .enabled={enabled} }}; """) diff --git a/cpp/include/Ice/LocalExceptions.h b/cpp/include/Ice/LocalExceptions.h index aaaeead83e8..69766fb18a0 100644 --- a/cpp/include/Ice/LocalExceptions.h +++ b/cpp/include/Ice/LocalExceptions.h @@ -934,9 +934,10 @@ namespace Ice }; /** - * An unknown property was used when trying to get or set an unknown property. + * This exception is raised during the getting or setting of an Ice property. For example, this can happen when + * trying to set an unknown property or when the property value is invalid. */ - class ICE_API UnknownPropertyException final : public LocalException + class ICE_API PropertyException final : public LocalException { public: using LocalException::LocalException; diff --git a/cpp/src/Ice/LocalExceptions.cpp b/cpp/src/Ice/LocalExceptions.cpp index e67818190f5..8648cb20e28 100644 --- a/cpp/src/Ice/LocalExceptions.cpp +++ b/cpp/src/Ice/LocalExceptions.cpp @@ -453,7 +453,7 @@ Ice::TwowayOnlyException::ice_id() const noexcept } const char* -Ice::UnknownPropertyException::ice_id() const noexcept +Ice::PropertyException::ice_id() const noexcept { - return "::Ice::UnknownPropertyException"; + return "::Ice::PropertyException"; } diff --git a/cpp/src/Ice/MetricsAdminI.cpp b/cpp/src/Ice/MetricsAdminI.cpp index 3e97b6096d4..44303bc7eaf 100644 --- a/cpp/src/Ice/MetricsAdminI.cpp +++ b/cpp/src/Ice/MetricsAdminI.cpp @@ -62,7 +62,7 @@ namespace { os << "\n " << prop; } - throw UnknownPropertyException{__FILE__, __LINE__, os.str()}; + throw PropertyException{__FILE__, __LINE__, os.str()}; } } diff --git a/cpp/src/Ice/Properties.cpp b/cpp/src/Ice/Properties.cpp index 222cbad53fd..1c07b50a20e 100644 --- a/cpp/src/Ice/Properties.cpp +++ b/cpp/src/Ice/Properties.cpp @@ -53,14 +53,14 @@ namespace /// Find the default value for an Ice property. If there is no default value, return an empty string. /// @param key The ice property name. /// @return The default value for the property. - /// @throws UnknownPropertyException if the property is unknown. + /// @throws PropertyException if the property is unknown. string_view getDefaultValue(string_view key) { auto propertyArray = findIcePropertyArray(key); if (!propertyArray) { - throw UnknownPropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; + throw PropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; } // The Ice property prefix. @@ -70,7 +70,7 @@ namespace if (!prop) { - throw UnknownPropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; + throw PropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; } return prop->defaultValue; @@ -319,11 +319,15 @@ Ice::Properties::setProperty(string_view key, string_view value) // Check if the property is in an Ice property prefix. If so, check that it's a valid property. if (auto propertyArray = findIcePropertyArray(key)) { + if (!propertyArray->enabled) + { + throw PropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; + } string propertyPrefix{propertyArray->name}; auto prop = IceInternal::findProperty(key.substr(propertyPrefix.length() + 1), propertyArray); if (!prop) { - throw UnknownPropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; + throw PropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; } // If the property is deprecated, log a warning. diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 7a6138cffd4..b94f3a51e6d 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -24,10 +24,11 @@ const Property ProxyPropsData[] = const PropertyArray PropertyNames::ProxyProps { - "Proxy", - false, - ProxyPropsData, - 9 + .name="Proxy", + .prefixOnly=false, + .properties=ProxyPropsData, + .length=9, + .enabled=false }; const Property ConnectionPropsData[] = @@ -42,10 +43,11 @@ const Property ConnectionPropsData[] = const PropertyArray PropertyNames::ConnectionProps { - "Connection", - true, - ConnectionPropsData, - 6 + .name="Connection", + .prefixOnly=true, + .properties=ConnectionPropsData, + .length=6, + .enabled=false }; const Property ThreadPoolPropsData[] = @@ -59,10 +61,11 @@ const Property ThreadPoolPropsData[] = const PropertyArray PropertyNames::ThreadPoolProps { - "ThreadPool", - true, - ThreadPoolPropsData, - 5 + .name="ThreadPool", + .prefixOnly=true, + .properties=ThreadPoolPropsData, + .length=5, + .enabled=false }; const Property ObjectAdapterPropsData[] = @@ -83,10 +86,11 @@ const Property ObjectAdapterPropsData[] = const PropertyArray PropertyNames::ObjectAdapterProps { - "ObjectAdapter", - true, - ObjectAdapterPropsData, - 12 + .name="ObjectAdapter", + .prefixOnly=true, + .properties=ObjectAdapterPropsData, + .length=12, + .enabled=false }; const Property LMDBPropsData[] = @@ -97,10 +101,11 @@ const Property LMDBPropsData[] = const PropertyArray PropertyNames::LMDBProps { - "LMDB", - true, - LMDBPropsData, - 2 + .name="LMDB", + .prefixOnly=true, + .properties=LMDBPropsData, + .length=2, + .enabled=false }; const Property IcePropsData[] = @@ -192,28 +197,11 @@ const Property IcePropsData[] = const PropertyArray PropertyNames::IceProps { - "Ice", - false, - IcePropsData, - 83 -}; - -const Property IceMXPropsData[] = -{ - Property{"Metrics.*.GroupBy", "", true, false, nullptr}, - Property{"Metrics.*.Map", "", true, false, nullptr}, - Property{"Metrics.*.RetainDetached", "10", true, false, nullptr}, - Property{"Metrics.*.Accept", "", true, false, nullptr}, - Property{"Metrics.*.Reject", "", true, false, nullptr}, - Property{"Metrics.*", "", true, false, nullptr} -}; - -const PropertyArray PropertyNames::IceMXProps -{ - "IceMX", - false, - IceMXPropsData, - 6 + .name="Ice", + .prefixOnly=false, + .properties=IcePropsData, + .length=83, + .enabled=false }; const Property IceDiscoveryPropsData[] = @@ -233,10 +221,11 @@ const Property IceDiscoveryPropsData[] = const PropertyArray PropertyNames::IceDiscoveryProps { - "IceDiscovery", - false, - IceDiscoveryPropsData, - 11 + .name="IceDiscovery", + .prefixOnly=false, + .properties=IceDiscoveryPropsData, + .length=11, + .enabled=false }; const Property IceLocatorDiscoveryPropsData[] = @@ -256,10 +245,11 @@ const Property IceLocatorDiscoveryPropsData[] = const PropertyArray PropertyNames::IceLocatorDiscoveryProps { - "IceLocatorDiscovery", - false, - IceLocatorDiscoveryPropsData, - 11 + .name="IceLocatorDiscovery", + .prefixOnly=false, + .properties=IceLocatorDiscoveryPropsData, + .length=11, + .enabled=false }; const Property IceBoxPropsData[] = @@ -274,10 +264,11 @@ const Property IceBoxPropsData[] = const PropertyArray PropertyNames::IceBoxProps { - "IceBox", - false, - IceBoxPropsData, - 6 + .name="IceBox", + .prefixOnly=false, + .properties=IceBoxPropsData, + .length=6, + .enabled=false }; const Property IceBoxAdminPropsData[] = @@ -287,10 +278,11 @@ const Property IceBoxAdminPropsData[] = const PropertyArray PropertyNames::IceBoxAdminProps { - "IceBoxAdmin", - false, - IceBoxAdminPropsData, - 1 + .name="IceBoxAdmin", + .prefixOnly=false, + .properties=IceBoxAdminPropsData, + .length=1, + .enabled=false }; const Property IceBridgePropsData[] = @@ -302,10 +294,11 @@ const Property IceBridgePropsData[] = const PropertyArray PropertyNames::IceBridgeProps { - "IceBridge", - false, - IceBridgePropsData, - 3 + .name="IceBridge", + .prefixOnly=false, + .properties=IceBridgePropsData, + .length=3, + .enabled=false }; const Property IceGridAdminPropsData[] = @@ -327,10 +320,11 @@ const Property IceGridAdminPropsData[] = const PropertyArray PropertyNames::IceGridAdminProps { - "IceGridAdmin", - false, - IceGridAdminPropsData, - 13 + .name="IceGridAdmin", + .prefixOnly=false, + .properties=IceGridAdminPropsData, + .length=13, + .enabled=false }; const Property IceGridPropsData[] = @@ -399,10 +393,11 @@ const Property IceGridPropsData[] = const PropertyArray PropertyNames::IceGridProps { - "IceGrid", - false, - IceGridPropsData, - 60 + .name="IceGrid", + .prefixOnly=false, + .properties=IceGridPropsData, + .length=60, + .enabled=false }; const Property IceSSLPropsData[] = @@ -432,10 +427,11 @@ const Property IceSSLPropsData[] = const PropertyArray PropertyNames::IceSSLProps { - "IceSSL", - false, - IceSSLPropsData, - 21 + .name="IceSSL", + .prefixOnly=false, + .properties=IceSSLPropsData, + .length=21, + .enabled=false }; const Property IceStormPropsData[] = @@ -468,10 +464,11 @@ const Property IceStormPropsData[] = const PropertyArray PropertyNames::IceStormProps { - "IceStorm", - false, - IceStormPropsData, - 24 + .name="IceStorm", + .prefixOnly=false, + .properties=IceStormPropsData, + .length=24, + .enabled=false }; const Property IceStormAdminPropsData[] = @@ -483,10 +480,11 @@ const Property IceStormAdminPropsData[] = const PropertyArray PropertyNames::IceStormAdminProps { - "IceStormAdmin", - false, - IceStormAdminPropsData, - 3 + .name="IceStormAdmin", + .prefixOnly=false, + .properties=IceStormAdminPropsData, + .length=3, + .enabled=false }; const Property IceBTPropsData[] = @@ -497,10 +495,11 @@ const Property IceBTPropsData[] = const PropertyArray PropertyNames::IceBTProps { - "IceBT", - false, - IceBTPropsData, - 2 + .name="IceBT", + .prefixOnly=false, + .properties=IceBTPropsData, + .length=2, + .enabled=false }; const Property Glacier2PropsData[] = @@ -533,10 +532,11 @@ const Property Glacier2PropsData[] = const PropertyArray PropertyNames::Glacier2Props { - "Glacier2", - false, - Glacier2PropsData, - 24 + .name="Glacier2", + .prefixOnly=false, + .properties=Glacier2PropsData, + .length=24, + .enabled=false }; const Property DataStormPropsData[] = @@ -557,16 +557,16 @@ const Property DataStormPropsData[] = const PropertyArray PropertyNames::DataStormProps { - "DataStorm", - false, - DataStormPropsData, - 12 + .name="DataStorm", + .prefixOnly=false, + .properties=DataStormPropsData, + .length=12, + .enabled=false }; -const std::array PropertyNames::validProps = +const std::array PropertyNames::validProps = { IceProps, - IceMXProps, IceDiscoveryProps, IceLocatorDiscoveryProps, IceBoxProps, diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index a279279e2e3..f37d26ff92d 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -31,6 +31,7 @@ namespace IceInternal const bool prefixOnly; const Property* properties; const int length; + const bool enabled; }; class PropertyNames @@ -42,7 +43,6 @@ namespace IceInternal static const PropertyArray ObjectAdapterProps; static const PropertyArray LMDBProps; static const PropertyArray IceProps; - static const PropertyArray IceMXProps; static const PropertyArray IceDiscoveryProps; static const PropertyArray IceLocatorDiscoveryProps; static const PropertyArray IceBoxProps; @@ -57,7 +57,7 @@ namespace IceInternal static const PropertyArray Glacier2Props; static const PropertyArray DataStormProps; - static const std::array validProps; + static const std::array validProps; }; } diff --git a/cpp/src/Ice/PropertyUtil.cpp b/cpp/src/Ice/PropertyUtil.cpp index 65bc6527768..b1883f6fcda 100644 --- a/cpp/src/Ice/PropertyUtil.cpp +++ b/cpp/src/Ice/PropertyUtil.cpp @@ -95,6 +95,6 @@ IceInternal::validatePropertiesWithPrefix( os << "\n " << prop; } - throw UnknownPropertyException{__FILE__, __LINE__, os.str()}; + throw PropertyException{__FILE__, __LINE__, os.str()}; } } diff --git a/cpp/test/Ice/properties/Client.cpp b/cpp/test/Ice/properties/Client.cpp index bb247f3df23..9a38635745b 100644 --- a/cpp/test/Ice/properties/Client.cpp +++ b/cpp/test/Ice/properties/Client.cpp @@ -145,7 +145,7 @@ Client::run(int, char**) properties->getIceProperty("Ice.UnknownProperty"); test(false); } - catch (const Ice::UnknownPropertyException&) + catch (const Ice::PropertyException&) { } cout << "ok" << endl; @@ -159,7 +159,7 @@ Client::run(int, char**) properties->setProperty("Ice.UnknownProperty", "value"); test(false); } - catch (const Ice::UnknownPropertyException&) + catch (const Ice::PropertyException&) { } cout << "ok" << endl; @@ -177,7 +177,7 @@ Client::run(int, char**) Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("FooOA"); test(false); } - catch (const Ice::UnknownPropertyException&) + catch (const Ice::PropertyException&) { } cout << "ok" << endl; @@ -190,7 +190,7 @@ Client::run(int, char**) communicator->propertyToProxy("FooProxy"); test(false); } - catch (const Ice::UnknownPropertyException&) + catch (const Ice::PropertyException&) { } } diff --git a/csharp/src/Ice/Internal/PropertyNames.cs b/csharp/src/Ice/Internal/PropertyNames.cs index 93ae900eaea..9b0a2388f87 100644 --- a/csharp/src/Ice/Internal/PropertyNames.cs +++ b/csharp/src/Ice/Internal/PropertyNames.cs @@ -155,18 +155,6 @@ internal sealed class PropertyNames new(pattern: @"CacheMessageBuffers", usesRegex: false, defaultValue: "2", deprecated: false, propertyArray: null) ]); - internal static PropertyArray IceMXProps = new( - "IceMX", - false, - [ - new(pattern: @"^Metrics\.[^\s]+\.GroupBy$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), - new(pattern: @"^Metrics\.[^\s]+\.Map$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), - new(pattern: @"^Metrics\.[^\s]+\.RetainDetached$", usesRegex: true, defaultValue: "10", deprecated: false, propertyArray: null), - new(pattern: @"^Metrics\.[^\s]+\.Accept$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), - new(pattern: @"^Metrics\.[^\s]+\.Reject$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), - new(pattern: @"^Metrics\.[^\s]+$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null) - ]); - internal static PropertyArray IceDiscoveryProps = new( "IceDiscovery", false, @@ -283,7 +271,6 @@ internal sealed class PropertyNames internal static PropertyArray[] validProps = [ IceProps, - IceMXProps, IceDiscoveryProps, IceLocatorDiscoveryProps, IceBoxProps, diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java index 9dbc57c8612..bc8bfe6dbf4 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java @@ -2,9 +2,6 @@ package com.zeroc.Ice; -import com.zeroc.Ice.Instrumentation.CommunicatorObserver; -import com.zeroc.Ice.SSL.SSLEngineFactory; - import java.net.InetAddress; import java.util.ArrayList; import java.util.List; @@ -12,6 +9,9 @@ import java.util.Stack; import java.util.function.Function; +import com.zeroc.Ice.Instrumentation.CommunicatorObserver; +import com.zeroc.Ice.SSL.SSLEngineFactory; + /** * The object adapter provides an up-call interface from the Ice run time to the implementation of * Ice objects. The object adapter is responsible for receiving requests from endpoints, and for @@ -1119,6 +1119,7 @@ public int messageSizeMax() { try { _reference = _instance.referenceFactory().create("dummy " + proxyOptions, ""); } catch (ParseException ex) { + _state = StateDestroyed; throw new InitializationException( "invalid proxy options '" + proxyOptions diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java b/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java index d8c0a8777b0..935e199d650 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java @@ -160,18 +160,6 @@ final class PropertyNames new Property("ThreadInterruptSafe", false, "", false, null) }); - public static final PropertyArray IceMXProps = new PropertyArray( - "IceMX", - false, - new Property[] { - new Property("Metrics\\.[^\\s]+\\.GroupBy", true, "", false, null), - new Property("Metrics\\.[^\\s]+\\.Map", true, "", false, null), - new Property("Metrics\\.[^\\s]+\\.RetainDetached", true, "10", false, null), - new Property("Metrics\\.[^\\s]+\\.Accept", true, "", false, null), - new Property("Metrics\\.[^\\s]+\\.Reject", true, "", false, null), - new Property("Metrics\\.[^\\s]+", true, "", false, null) - }); - public static final PropertyArray IceDiscoveryProps = new PropertyArray( "IceDiscovery", false, @@ -304,7 +292,6 @@ final class PropertyNames public static final PropertyArray validProps[] = { IceProps, - IceMXProps, IceDiscoveryProps, IceLocatorDiscoveryProps, IceBoxProps, diff --git a/js/src/Ice/PropertyNames.js b/js/src/Ice/PropertyNames.js index 240b21bb5ac..a1f51f2bf86 100644 --- a/js/src/Ice/PropertyNames.js +++ b/js/src/Ice/PropertyNames.js @@ -73,9 +73,6 @@ PropertyNames.IceProps = new PropertyArray("Ice", false, [ new Property("Warn.UnusedProperties", false, "0", false, null) ]); -PropertyNames.IceMXProps = new PropertyArray("IceMX", false, [ -]); - PropertyNames.IceDiscoveryProps = new PropertyArray("IceDiscovery", false, [ ]); @@ -117,7 +114,6 @@ PropertyNames.DataStormProps = new PropertyArray("DataStorm", false, [ PropertyNames.validProps = [ PropertyNames.IceProps, - PropertyNames.IceMXProps, PropertyNames.IceDiscoveryProps, PropertyNames.IceLocatorDiscoveryProps, PropertyNames.IceBoxProps, From 554407830d360129fc48a893568d2dd7ff06394f Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 28 Oct 2024 10:56:15 -0400 Subject: [PATCH 02/10] Fixes --- .github/workflows/ci.yml | 11 +- config/PropertyNames.xml | 32 +++--- config/makeprops.py | 21 ++-- cpp/include/DataStorm/Node.h | 103 +++++++++++++++--- cpp/include/Ice/Properties.h | 10 ++ cpp/src/DataStorm/Node.cpp | 77 ++++++++++++- cpp/src/Glacier2/Glacier2Router.cpp | 3 +- cpp/src/Ice/Properties.cpp | 8 +- cpp/src/Ice/PropertyNames.cpp | 60 ++++++---- cpp/src/Ice/PropertyNames.h | 5 +- cpp/src/IceBox/Admin.cpp | 6 +- cpp/src/IceBox/IceBoxService.cpp | 14 +-- cpp/src/IceBox/ServiceManagerI.cpp | 44 ++++---- cpp/src/IceBox/ServiceManagerI.h | 5 +- cpp/src/IceBridge/IceBridge.cpp | 3 +- cpp/src/IceGrid/Client.cpp | 3 +- cpp/src/IceGrid/IceGridNode.cpp | 3 +- cpp/src/IceGrid/IceGridRegistry.cpp | 3 +- cpp/src/IceStorm/Admin.cpp | 7 +- cpp/src/dsnode/Node.cpp | 5 +- cpp/test/DataStorm/api/Writer.cpp | 9 +- cpp/test/DataStorm/callbacks/Reader.cpp | 2 +- cpp/test/DataStorm/callbacks/Writer.cpp | 2 +- cpp/test/Ice/properties/Client.cpp | 12 ++ cpp/test/IceBox/configuration/AllTests.cpp | 4 +- cpp/test/IceBox/configuration/config.icebox | 2 +- cpp/test/IceBox/configuration/config.icebox2 | 2 + cpp/test/IceStorm/federation/Publisher.cpp | 2 +- cpp/test/IceStorm/federation/Subscriber.cpp | 2 +- cpp/test/IceStorm/federation2/Publisher.cpp | 2 +- cpp/test/IceStorm/federation2/Subscriber.cpp | 2 +- cpp/test/IceStorm/persistent/Client.cpp | 2 +- cpp/test/IceStorm/rep1/Publisher.cpp | 2 +- cpp/test/IceStorm/rep1/Sub.cpp | 2 +- cpp/test/IceStorm/rep1/Subscriber.cpp | 2 +- cpp/test/IceStorm/repstress/Publisher.cpp | 2 +- cpp/test/IceStorm/repstress/Subscriber.cpp | 2 +- cpp/test/IceStorm/single/Publisher.cpp | 2 +- cpp/test/IceStorm/single/Subscriber.cpp | 2 +- cpp/test/IceStorm/stress/Publisher.cpp | 2 +- cpp/test/IceStorm/stress/Subscriber.cpp | 2 +- csharp/src/Ice/Internal/PropertyNames.cs | 13 +++ .../java/com/zeroc/Ice/ObjectAdapter.java | 6 +- .../java/com/zeroc/Ice/PropertyNames.java | 13 +++ .../com/zeroc/IceBox/ServiceManagerI.java | 5 +- js/src/Ice/PropertyNames.js | 5 + scripts/IceStormUtil.py | 6 +- 47 files changed, 373 insertions(+), 159 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd9bb292fde..7fcda668691 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,8 +118,9 @@ jobs: if-no-files-found: ignore if: always() - # - name: Test Summary - # uses: test-summary/action@v2 - # with: - # paths: "${{ matrix.working_directory || '.' }}/test-report.xml" - # if: always() + - name: Upload macOS crash diagnostics + uses: actions/upload-artifact@v4 + with: + name: crash-diagnostics-${{ matrix.config }}-${{ matrix.os }} + path: ~/Library/Logs/DiagnosticReports/*.ips + if: runner.os == 'macOS' && always() diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 7cb335b34fd..708bf1f3662 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -65,7 +65,7 @@ --> -
+
@@ -160,16 +160,16 @@
- +
-
+
@@ -184,7 +184,7 @@
-
+
@@ -198,7 +198,7 @@
-
+
@@ -207,17 +207,17 @@
-
+
-
+
-
+
@@ -236,7 +236,7 @@
-
+
@@ -301,7 +301,7 @@
-
+
@@ -333,7 +333,7 @@
-
+
@@ -360,18 +360,18 @@
-
+
-
+
-
+
@@ -398,7 +398,7 @@
-
+
diff --git a/config/makeprops.py b/config/makeprops.py index 14a423abbdd..ad04d445d42 100755 --- a/config/makeprops.py +++ b/config/makeprops.py @@ -35,10 +35,12 @@ class Language(StrEnum): class PropertyArray: - def __init__(self, name: str, prefixOnly: bool, isClass: bool, enabled: bool): + def __init__( + self, name: str, prefixOnly: bool, isClass: bool, isServicePrefix: bool + ): self.name = name self.prefixOnly = prefixOnly - self.enabled = False + self.isServicePrefix = isServicePrefix self.isClass = isClass self.properties = [] @@ -183,7 +185,6 @@ def startElement(self, name, attrs): case "class": name = f"{attrs.get("name")}" prefixOnly = attrs.get("prefix-only", "false").lower() == "true" - enabled = attrs.get("enabled", "true").lower() == "true" self.validateKnownAttributes(["name", "prefix-only"], attrs) self.parentNodeName = name @@ -191,19 +192,19 @@ def startElement(self, name, attrs): name=name, prefixOnly=prefixOnly, isClass=True, - enabled=enabled, + isServicePrefix=False, ) case "section": - enabled = attrs.get("enabled", "true").lower() == "true" + isServicePrefix = attrs.get("service-prefix", "false").lower() == "true" name = attrs.get("name") - self.validateKnownAttributes(["name", "enabled"], attrs) + self.validateKnownAttributes(["name", "service-prefix"], attrs) self.parentNodeName = name self.propertyArrayDict[self.parentNodeName] = PropertyArray( name=name, prefixOnly=False, isClass=False, - enabled=enabled, + isServicePrefix=isServicePrefix, ) case "property": @@ -276,7 +277,7 @@ def openFiles(self): const bool prefixOnly; const Property* properties; const int length; - const bool enabled; + const bool isServicePrefix; }}; class PropertyNames @@ -318,7 +319,7 @@ def fix(self, propertyName): def writePropertyArray(self, propertyArray): name = propertyArray.name prefixOnly = "true" if propertyArray.prefixOnly else "false" - enabled = "true" if propertyArray.enabled else "false" + isServicePrefix = "true" if propertyArray.isServicePrefix else "false" self.hFile.write(f" static const PropertyArray {name}Props;\n") self.cppFile.write(f"""\ @@ -333,7 +334,7 @@ def writePropertyArray(self, propertyArray): .prefixOnly={prefixOnly}, .properties={name}PropsData, .length={len(propertyArray.properties)}, - .enabled={enabled} + .isServicePrefix={isServicePrefix} }}; """) diff --git a/cpp/include/DataStorm/Node.h b/cpp/include/DataStorm/Node.h index 2f780e7b9ad..aa71c1f8761 100644 --- a/cpp/include/DataStorm/Node.h +++ b/cpp/include/DataStorm/Node.h @@ -38,47 +38,115 @@ namespace DataStorm /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The constructor initializes - * the Ice communicator using the given arguments. If the communicator creation fails, an Ice exception is - * raised. + * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice + * communicator. + * + * @param argc The number of arguments in argv. + * @param argv The configuration arguments. + * @param configFile The path to an optional Ice configuration file. + * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is + * provided the Node will use the default callback executor that executes callback in a dedicated thread. * - * @param iceArgs Arguments which are passed to the Ice::initialize function. */ - template Node(T&&... iceArgs) : _ownsCommunicator(true) + Node( + int& argc, + const char* argv[], + std::optional configFile = std::nullopt, + std::function call)> customExecutor = nullptr); + + /** + * Construct a DataStorm node. + * + * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice + * communicator. + * + * @param argc The number of arguments in argv. + * @param argv The configuration arguments. + * @param configFile The path to an optional Ice configuration file. + * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is + * provided the Node will use the default callback executor that executes callback in a dedicated thread. + * + */ + Node( + int& argc, + char* argv[], + std::optional configFile = std::nullopt, + std::function call)> customExecutor = nullptr) + : Node(argc, const_cast(argv), configFile, customExecutor) { - init(Ice::initialize(std::forward(iceArgs)...), nullptr); } +#ifdef _WIN32 /** * Construct a DataStorm node. * * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice * communicator. * - * @param communicator The Ice communicator used by the topic factory for its configuration and communications. + * @param argc The number of arguments in argv. + * @param argv The configuration arguments. + * @param configFile The path to an optional Ice configuration file. * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is * provided the Node will use the default callback executor that executes callback in a dedicated thread. + * */ Node( - Ice::CommunicatorPtr communicator, + int& argc, + const wchar_t* argv[], + std::optional configFile = std::nullopt, std::function call)> customExecutor = nullptr); /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The constructor initializes - * the Ice communicator using the given arguments. If the communicator creation fails, an Ice exception is - * raised. + * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice + * communicator. * + * @param argc The number of arguments in argv. + * @param argv The configuration arguments. + * @param configFile The path to an optional Ice configuration file. * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is * provided the Node will use the default callback executor that executes callback in a dedicated thread. - * @param iceArgs Arguments which are passed to the Ice::initialize function. + * */ - template - Node(std::function call)> customExecutor, T&&... iceArgs) : _ownsCommunicator(true) + Node( + int& argc, + wchar_t* argv[], + std::optional configFile = std::nullopt, + std::function call)> customExecutor = nullptr) + : Node(argc, const_cast(argv), configFile, customExecutor) { - init(Ice::initialize(std::forward(iceArgs)...), std::move(customExecutor)); } +#endif + + /** + * Construct a DataStorm node. + * + * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice + * communicator. + * + * @param configFile The path to an optional Ice configuration file. + * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is + * provided the Node will use the default callback executor that executes callback in a dedicated thread. + */ + Node( + std::optional configFile = std::nullopt, + std::function call)> customExecutor = nullptr); + + /** + * Construct a DataStorm node. + * + * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice + * communicator. + * + * @param communicator The Ice communicator used by the topic factory for its configuration and communications. + * This communicator must be initialized with a property set to use the "DataStorm" service prefix. + * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is + * provided the Node will use the default callback executor that executes callback in a dedicated thread. + */ + Node( + Ice::CommunicatorPtr communicator, + std::function call)> customExecutor = nullptr); /** * Construct a new Node by taking ownership of the given node. @@ -133,7 +201,10 @@ namespace DataStorm Ice::ConnectionPtr getSessionConnection(const std::string& ident) const noexcept; private: - void init(const Ice::CommunicatorPtr&, std::function call)> customExecutor); + Node( + const Ice::CommunicatorPtr&, + std::function call)> customExecutor, + bool ownsCommunicator); std::shared_ptr _instance; std::shared_ptr _factory; diff --git a/cpp/include/Ice/Properties.h b/cpp/include/Ice/Properties.h index 616fb8b9f9c..b56b509e034 100644 --- a/cpp/include/Ice/Properties.h +++ b/cpp/include/Ice/Properties.h @@ -34,6 +34,12 @@ namespace Ice */ Properties() = default; + /** + * Constructs an empty property set with the given property service prefix. + * @param servicePrefix The property set to copy. + */ + explicit Properties(std::string_view servicePrefix) : _servicePrefix(servicePrefix) {} + /** * Copy constructor. * @param source The property set to copy. @@ -213,6 +219,8 @@ namespace Ice static std::optional> parseLine(std::string_view, const StringConverterPtr&); + void loadArgs(StringSeq&); + void loadConfig(); struct PropertyValue @@ -225,6 +233,8 @@ namespace Ice bool used; }; std::map> _properties; + // The service prefix is used to allow Ice services to set service specific prefixed properties. + std::optional _servicePrefix; mutable std::mutex _mutex; }; } diff --git a/cpp/src/DataStorm/Node.cpp b/cpp/src/DataStorm/Node.cpp index de6d3f8c8ee..2ec800c52c8 100644 --- a/cpp/src/DataStorm/Node.cpp +++ b/cpp/src/DataStorm/Node.cpp @@ -11,20 +11,89 @@ using namespace std; using namespace DataStorm; +namespace +{ + + Ice::CommunicatorPtr argsToCommunicator(int& argc, const char* argv[], optional configFile) + { + Ice::PropertiesPtr properties = make_shared("DataStorm"); + + if (configFile) + { + properties->load(*configFile); + } + + return Ice::initialize(argc, argv, {.properties = properties}); + } + +#ifdef _WIN32 + Ice::CommunicatorPtr argsToCommunicator(int& argc, const wchar_t* argv[], optional configFile) + { + Ice::PropertiesPtr properties = make_shared("DataStorm"); + + if (configFile) + { + properties->load(*configFile); + } + + return Ice::initialize(argc, argv, {.properties = properties}); + } +#endif + + Ice::CommunicatorPtr configToCommunicator(optional configFile) + { + Ice::PropertiesPtr properties = make_shared("DataStorm"); + + if (configFile) + { + properties->load(*configFile); + } + + return Ice::initialize({.properties = properties}); + } +} + const char* NodeShutdownException::what() const noexcept { return "::DataStorm::NodeShutdownException"; } +Node::Node( + int& argc, + const char* argv[], + optional configFile, + function call)> customExecutor) + : Node(argsToCommunicator(argc, argv, configFile), std::move(customExecutor), true) +{ +} + +#ifdef _WIN32 +Node::Node( + int& argc, + const wchar_t* argv[], + optional configFile, + function call)> customExecutor) + : Node(argsToCommunicator(argc, argv, configFile), std::move(customExecutor), true) +{ +} +#endif + +Node::Node(optional configFile, function call)> customExecutor) + : Node(configToCommunicator(configFile), std::move(customExecutor), true) +{ +} + Node::Node(Ice::CommunicatorPtr communicator, function call)> callbackExecutor) - : _ownsCommunicator(false) + : Node(std::move(communicator), std::move(callbackExecutor), false) { - init(communicator, std::move(callbackExecutor)); } -void -Node::init(const Ice::CommunicatorPtr& communicator, std::function call)> callbackExecutor) +Node::Node( + const Ice::CommunicatorPtr& communicator, + std::function call)> callbackExecutor, + bool ownsCommunicator) + : _ownsCommunicator(ownsCommunicator) { try { diff --git a/cpp/src/Glacier2/Glacier2Router.cpp b/cpp/src/Glacier2/Glacier2Router.cpp index 5072811a543..e0fc9b32797 100644 --- a/cpp/src/Glacier2/Glacier2Router.cpp +++ b/cpp/src/Glacier2/Glacier2Router.cpp @@ -490,5 +490,6 @@ main(int argc, char* argv[]) #endif { RouterService svc; - return svc.main(argc, argv); + // Initialize the service with a Properties object with the correct property prefix enabled. + return svc.main(argc, argv, {.properties = make_shared("Glacier2")}); } diff --git a/cpp/src/Ice/Properties.cpp b/cpp/src/Ice/Properties.cpp index 1c07b50a20e..4459aea37ac 100644 --- a/cpp/src/Ice/Properties.cpp +++ b/cpp/src/Ice/Properties.cpp @@ -89,6 +89,7 @@ Ice::Properties::Properties(StringSeq& args, const PropertiesPtr& defaults) { lock_guard lock(defaults->_mutex); _properties = defaults->_properties; + _servicePrefix = defaults->_servicePrefix; } StringSeq::iterator q = args.begin(); @@ -319,9 +320,12 @@ Ice::Properties::setProperty(string_view key, string_view value) // Check if the property is in an Ice property prefix. If so, check that it's a valid property. if (auto propertyArray = findIcePropertyArray(key)) { - if (!propertyArray->enabled) + if (propertyArray->isServicePrefix && + (_servicePrefix != propertyArray->name && propertyArray->name != string{"IceStorm"})) { - throw PropertyException{__FILE__, __LINE__, "unknown Ice property: " + string{key}}; + ostringstream os; + os << "unable to set '" << key << "': property prefix '" << propertyArray->name << "' is reserved."; + throw PropertyException{__FILE__, __LINE__, os.str()}; } string propertyPrefix{propertyArray->name}; auto prop = IceInternal::findProperty(key.substr(propertyPrefix.length() + 1), propertyArray); diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 23c0b982187..e807c7e23ab 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -28,7 +28,7 @@ const PropertyArray PropertyNames::ProxyProps .prefixOnly=false, .properties=ProxyPropsData, .length=9, - .enabled=false + .isServicePrefix=false }; const Property ConnectionPropsData[] = @@ -47,7 +47,7 @@ const PropertyArray PropertyNames::ConnectionProps .prefixOnly=true, .properties=ConnectionPropsData, .length=6, - .enabled=false + .isServicePrefix=false }; const Property ThreadPoolPropsData[] = @@ -65,7 +65,7 @@ const PropertyArray PropertyNames::ThreadPoolProps .prefixOnly=true, .properties=ThreadPoolPropsData, .length=5, - .enabled=false + .isServicePrefix=false }; const Property ObjectAdapterPropsData[] = @@ -90,7 +90,7 @@ const PropertyArray PropertyNames::ObjectAdapterProps .prefixOnly=true, .properties=ObjectAdapterPropsData, .length=12, - .enabled=false + .isServicePrefix=false }; const Property LMDBPropsData[] = @@ -105,7 +105,7 @@ const PropertyArray PropertyNames::LMDBProps .prefixOnly=true, .properties=LMDBPropsData, .length=2, - .enabled=false + .isServicePrefix=false }; const Property IcePropsData[] = @@ -201,7 +201,26 @@ const PropertyArray PropertyNames::IceProps .prefixOnly=false, .properties=IcePropsData, .length=83, - .enabled=false + .isServicePrefix=false +}; + +const Property IceMXPropsData[] = +{ + Property{"Metrics.*.GroupBy", "", true, false, nullptr}, + Property{"Metrics.*.Map", "", true, false, nullptr}, + Property{"Metrics.*.RetainDetached", "10", true, false, nullptr}, + Property{"Metrics.*.Accept", "", true, false, nullptr}, + Property{"Metrics.*.Reject", "", true, false, nullptr}, + Property{"Metrics.*", "", true, false, nullptr} +}; + +const PropertyArray PropertyNames::IceMXProps +{ + .name="IceMX", + .prefixOnly=false, + .properties=IceMXPropsData, + .length=6, + .isServicePrefix=false }; const Property IceDiscoveryPropsData[] = @@ -225,7 +244,7 @@ const PropertyArray PropertyNames::IceDiscoveryProps .prefixOnly=false, .properties=IceDiscoveryPropsData, .length=11, - .enabled=false + .isServicePrefix=false }; const Property IceLocatorDiscoveryPropsData[] = @@ -249,7 +268,7 @@ const PropertyArray PropertyNames::IceLocatorDiscoveryProps .prefixOnly=false, .properties=IceLocatorDiscoveryPropsData, .length=11, - .enabled=false + .isServicePrefix=false }; const Property IceBoxPropsData[] = @@ -268,7 +287,7 @@ const PropertyArray PropertyNames::IceBoxProps .prefixOnly=false, .properties=IceBoxPropsData, .length=6, - .enabled=false + .isServicePrefix=true }; const Property IceBoxAdminPropsData[] = @@ -282,7 +301,7 @@ const PropertyArray PropertyNames::IceBoxAdminProps .prefixOnly=false, .properties=IceBoxAdminPropsData, .length=1, - .enabled=false + .isServicePrefix=true }; const Property IceBridgePropsData[] = @@ -298,7 +317,7 @@ const PropertyArray PropertyNames::IceBridgeProps .prefixOnly=false, .properties=IceBridgePropsData, .length=3, - .enabled=false + .isServicePrefix=true }; const Property IceGridAdminPropsData[] = @@ -324,7 +343,7 @@ const PropertyArray PropertyNames::IceGridAdminProps .prefixOnly=false, .properties=IceGridAdminPropsData, .length=13, - .enabled=false + .isServicePrefix=true }; const Property IceGridPropsData[] = @@ -399,7 +418,7 @@ const PropertyArray PropertyNames::IceGridProps .prefixOnly=false, .properties=IceGridPropsData, .length=62, - .enabled=false + .isServicePrefix=true }; const Property IceSSLPropsData[] = @@ -433,7 +452,7 @@ const PropertyArray PropertyNames::IceSSLProps .prefixOnly=false, .properties=IceSSLPropsData, .length=21, - .enabled=false + .isServicePrefix=false }; const Property IceStormPropsData[] = @@ -470,7 +489,7 @@ const PropertyArray PropertyNames::IceStormProps .prefixOnly=false, .properties=IceStormPropsData, .length=24, - .enabled=false + .isServicePrefix=true }; const Property IceStormAdminPropsData[] = @@ -486,7 +505,7 @@ const PropertyArray PropertyNames::IceStormAdminProps .prefixOnly=false, .properties=IceStormAdminPropsData, .length=3, - .enabled=false + .isServicePrefix=true }; const Property IceBTPropsData[] = @@ -501,7 +520,7 @@ const PropertyArray PropertyNames::IceBTProps .prefixOnly=false, .properties=IceBTPropsData, .length=2, - .enabled=false + .isServicePrefix=false }; const Property Glacier2PropsData[] = @@ -538,7 +557,7 @@ const PropertyArray PropertyNames::Glacier2Props .prefixOnly=false, .properties=Glacier2PropsData, .length=24, - .enabled=false + .isServicePrefix=true }; const Property DataStormPropsData[] = @@ -563,12 +582,13 @@ const PropertyArray PropertyNames::DataStormProps .prefixOnly=false, .properties=DataStormPropsData, .length=12, - .enabled=false + .isServicePrefix=true }; -const std::array PropertyNames::validProps = +const std::array PropertyNames::validProps = { IceProps, + IceMXProps, IceDiscoveryProps, IceLocatorDiscoveryProps, IceBoxProps, diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index f37d26ff92d..f6d885dfa3c 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -31,7 +31,7 @@ namespace IceInternal const bool prefixOnly; const Property* properties; const int length; - const bool enabled; + const bool isServicePrefix; }; class PropertyNames @@ -43,6 +43,7 @@ namespace IceInternal static const PropertyArray ObjectAdapterProps; static const PropertyArray LMDBProps; static const PropertyArray IceProps; + static const PropertyArray IceMXProps; static const PropertyArray IceDiscoveryProps; static const PropertyArray IceLocatorDiscoveryProps; static const PropertyArray IceBoxProps; @@ -57,7 +58,7 @@ namespace IceInternal static const PropertyArray Glacier2Props; static const PropertyArray DataStormProps; - static const std::array validProps; + static const std::array validProps; }; } diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp index bf394af5225..370542cac0a 100644 --- a/cpp/src/IceBox/Admin.cpp +++ b/cpp/src/IceBox/Admin.cpp @@ -32,7 +32,11 @@ main(int argc, char* argv[]) try { Ice::CtrlCHandler ctrlCHandler; - Ice::CommunicatorHolder ich(argc, argv); + + // Initialize with a Properties object with the correct property prefix enabled. + Ice::InitializationData initData{.properties = make_shared("IceBoxAdmin")}; + Ice::CommunicatorHolder ich{argc, argv, initData}; + communicator = ich.communicator(); ctrlCHandler.setCallback(&destroyCommunicator); diff --git a/cpp/src/IceBox/IceBoxService.cpp b/cpp/src/IceBox/IceBoxService.cpp index f679f8ad62d..b5e89fe6604 100644 --- a/cpp/src/IceBox/IceBoxService.cpp +++ b/cpp/src/IceBox/IceBoxService.cpp @@ -14,12 +14,9 @@ namespace IceBox { class IceBoxService : public Ice::Service { - public: - IceBoxService(); - protected: - virtual bool start(int, char*[], int&); - virtual bool stop(); + bool start(int, char*[], int&) final; + bool stop() final; private: void usage(const std::string&); @@ -27,8 +24,6 @@ namespace IceBox }; } -IceBox::IceBoxService::IceBoxService() {} - bool IceBox::IceBoxService::start(int argc, char* argv[], int& status) { @@ -87,7 +82,7 @@ IceBox::IceBoxService::start(int argc, char* argv[], int& status) return false; } - _serviceManager = ServiceManagerI::create(communicator(), argc, argv); + _serviceManager = make_shared(communicator(), argc, argv); return _serviceManager->start(); } @@ -135,7 +130,8 @@ main(int argc, char* argv[]) IceBox::IceBoxService svc; InitializationData initData; - initData.properties = createProperties(); + // Initialize the service with a Properties object with the correct property prefix enabled. + initData.properties = make_shared("IceBox"); initData.properties->setProperty("Ice.Admin.DelayCreation", "1"); return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 5257fa1c220..fb520475eae 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -29,7 +29,7 @@ namespace // // Split the entire property value into arguments. An entry point containing spaces // must be enclosed in quotes. - // + // p try { args = IceInternal::Options::split(value); @@ -65,13 +65,6 @@ namespace }; } -ServiceManagerIPtr -IceBox::ServiceManagerI::create(Ice::CommunicatorPtr communicator, int& argc, char* argv[]) -{ - ServiceManagerIPtr ptr(new ServiceManagerI(communicator, argc, argv)); - return ptr; -} - IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) : _communicator(communicator), _adminEnabled(false), @@ -362,9 +355,9 @@ IceBox::ServiceManagerI::start() InitializationData initData; initData.properties = createServiceProperties("SharedCommunicator"); - for (vector::iterator q = servicesInfo.begin(); q != servicesInfo.end(); ++q) + for (auto& info : servicesInfo) { - if (properties->getIcePropertyAsInt("IceBox.UseSharedCommunicator." + q->name) <= 0) + if (properties->getIcePropertyAsInt("IceBox.UseSharedCommunicator." + info.name) <= 0) { continue; } @@ -373,17 +366,17 @@ IceBox::ServiceManagerI::start() // Load the service properties using the shared communicator properties as // the default properties. // - PropertiesPtr svcProperties = createProperties(q->args, initData.properties); + PropertiesPtr svcProperties = createProperties(info.args, initData.properties); // // Remove properties from the shared property set that a service explicitly clears. // PropertyDict allProps = initData.properties->getPropertiesForPrefix(""); - for (PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p) + for (auto& p : allProps) { - if (svcProperties->getProperty(p->first) == "") + if (svcProperties->getProperty(p.first) == "") { - initData.properties->setProperty(p->first, ""); + initData.properties->setProperty(p.first, ""); } } @@ -391,16 +384,16 @@ IceBox::ServiceManagerI::start() // Add the service properties to the shared communicator properties. // PropertyDict props = svcProperties->getPropertiesForPrefix(""); - for (PropertyDict::const_iterator r = props.begin(); r != props.end(); ++r) + for (auto& r : props) { - initData.properties->setProperty(r->first, r->second); + initData.properties->setProperty(r.first, r.second); } // // Parse .* command line options (the Ice command line options // were parsed by the call to createProperties above). // - q->args = initData.properties->parseCommandLineOptions(q->name, q->args); + info.args = initData.properties->parseCommandLineOptions(info.name, info.args); } const string facetNamePrefix = "IceBox.SharedCommunicator."; @@ -522,7 +515,7 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, info.args = args; // - // If Ice.UseSharedCommunicator. is not defined, create + // If IceBox.UseSharedCommunicator. is not defined, create // a communicator for the service. The communicator inherits // from the shared communicator properties. If it's defined // add the service properties to the shared communicator @@ -858,17 +851,18 @@ IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, exc Ice::PropertiesPtr IceBox::ServiceManagerI::createServiceProperties(const string& service) { - PropertiesPtr properties; + // We don't want to clone the properties object as we don't want to copy the service prefix. + PropertiesPtr properties = make_shared(); PropertiesPtr communicatorProperties = _communicator->getProperties(); if (communicatorProperties->getPropertyAsInt("IceBox.InheritProperties") > 0) { - properties = communicatorProperties->clone(); - - // Inherit all except Ice.Admin.xxx properties - PropertyDict pd = properties->getPropertiesForPrefix("Ice.Admin."); - for (PropertyDict::const_iterator p = pd.begin(); p != pd.end(); ++p) + for (const auto& p : communicatorProperties->getPropertiesForPrefix("")) { - properties->setProperty(p->first, ""); + // Inherit all except IceBox. and Ice.Admin. properties + if (p.first.find("IceBox.") != 0 && p.first.find("Ice.Admin.") != 0) + { + properties->setProperty(p.first, p.second); + } } } else diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h index 33ec5c56dc5..1a8af039cbe 100644 --- a/cpp/src/IceBox/ServiceManagerI.h +++ b/cpp/src/IceBox/ServiceManagerI.h @@ -18,8 +18,7 @@ namespace IceBox class ServiceManagerI final : public ServiceManager, public std::enable_shared_from_this { public: - // Temporary: use public ctor once the implementation uses only the new mapping. - static ServiceManagerIPtr create(Ice::CommunicatorPtr, int&, char*[]); + ServiceManagerI(Ice::CommunicatorPtr, int&, char*[]); void startService(std::string, const Ice::Current&) final; void stopService(std::string, const Ice::Current&) final; @@ -54,8 +53,6 @@ namespace IceBox Ice::StringSeq args; }; - ServiceManagerI(Ice::CommunicatorPtr, int&, char*[]); - void start(const std::string&, const std::string&, const Ice::StringSeq&); void stopAll(); diff --git a/cpp/src/IceBridge/IceBridge.cpp b/cpp/src/IceBridge/IceBridge.cpp index 6c3c6894829..c46353a2dc9 100644 --- a/cpp/src/IceBridge/IceBridge.cpp +++ b/cpp/src/IceBridge/IceBridge.cpp @@ -629,5 +629,6 @@ main(int argc, char* argv[]) #endif { BridgeService svc; - return svc.main(argc, argv); + // Initialize the service with a Properties object with the correct property prefix enabled. + return svc.main(argc, argv, {.properties = make_shared("IceBridge")}); } diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index 8c21a277e91..425ee956ba8 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -79,7 +79,8 @@ main(int argc, char* argv[]) try { Ice::CtrlCHandler ctrlCHandler; - auto defaultProps = Ice::createProperties(); + // Initialize IceGrid properties with a Properties object with the correct property prefix enabled. + auto defaultProps = make_shared("IceGridAdmin"); defaultProps->setProperty("IceGridAdmin.Server.Endpoints", "tcp -h localhost"); Ice::InitializationData id; id.properties = createProperties(args, defaultProps); diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 50dfe1b737c..8df19b75847 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -813,5 +813,6 @@ main(int argc, char* argv[]) #endif { NodeService svc; - return svc.main(argc, argv); + // Initialize the service with a Properties object with the correct property prefix enabled. + return svc.main(argc, argv, {.properties = make_shared("IceGrid")}); } diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index 3c0fd28602f..1b2bc892945 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -231,5 +231,6 @@ main(int argc, char* argv[]) #endif { RegistryService svc; - return svc.main(argc, argv); + // Initialize the service with a Properties object with the correct property prefix enabled. + return svc.main(argc, argv, {.properties = make_shared("IceGrid")}); } diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp index 3a6827d142f..6f2367e3390 100644 --- a/cpp/src/IceStorm/Admin.cpp +++ b/cpp/src/IceStorm/Admin.cpp @@ -36,16 +36,15 @@ main(int argc, char* argv[]) Ice::CtrlCHandler ctrlCHandler; Ice::InitializationData id; - Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); - id.properties = Ice::createProperties(args); + id.properties = make_shared("IceStormAdmin"); id.properties->setProperty("Ice.Warn.Endpoints", "0"); - Ice::CommunicatorHolder ich(id); + Ice::CommunicatorHolder ich(argc, argv, id); auto communicator = ich.communicator(); ctrlCHandler.setCallback([communicator](int) { communicator->destroy(); }); - status = run(communicator, args); + status = run(communicator, Ice::argsToStringSeq(argc, argv)); } catch (const std::exception& ex) { diff --git a/cpp/src/dsnode/Node.cpp b/cpp/src/dsnode/Node.cpp index 4eb815d2d57..df60145ba2f 100644 --- a/cpp/src/dsnode/Node.cpp +++ b/cpp/src/dsnode/Node.cpp @@ -45,10 +45,7 @@ main(int argc, char* argv[]) // Ice::CtrlCHandler ctrlCHandler; - // - // Instantiates node. - // - DataStorm::Node node(argc, argv); + DataStorm::Node node{argc, argv}; if (argc > 1) { diff --git a/cpp/test/DataStorm/api/Writer.cpp b/cpp/test/DataStorm/api/Writer.cpp index 9c146288677..b8203669965 100644 --- a/cpp/test/DataStorm/api/Writer.cpp +++ b/cpp/test/DataStorm/api/Writer.cpp @@ -24,10 +24,11 @@ main(int argc, char* argv[]) nm2.getCommunicator(); nm2.getSessionConnection("s"); - Node n2(Ice::initialize()); + // Communicators shared with DataStorm must have a property set that can use the "DataStorm" service prefix. + Node n2(Ice::initialize({.properties = make_shared("DataStorm")})); n2.getCommunicator()->destroy(); - auto c = Ice::initialize(); + auto c = Ice::initialize({.properties = make_shared("DataStorm")}); { Node n22(c); } @@ -45,7 +46,7 @@ main(int argc, char* argv[]) } c->destroy(); - Node n3(Ice::InitializationData{}); + Node n3; try { @@ -55,7 +56,7 @@ main(int argc, char* argv[]) { } - Node n5(argc, argv, Ice::InitializationData{}); + Node n5(argc, argv); { Node n6; diff --git a/cpp/test/DataStorm/callbacks/Reader.cpp b/cpp/test/DataStorm/callbacks/Reader.cpp index 4f662bde14c..e532d115037 100644 --- a/cpp/test/DataStorm/callbacks/Reader.cpp +++ b/cpp/test/DataStorm/callbacks/Reader.cpp @@ -19,7 +19,7 @@ main(int argc, char* argv[]) callbackExecutor = [](function cb) { cb(); }; } } - Node node(callbackExecutor, argc, argv); + Node node(argc, argv, nullopt, callbackExecutor); ReaderConfig config; config.sampleCount = -1; // Unlimited sample count diff --git a/cpp/test/DataStorm/callbacks/Writer.cpp b/cpp/test/DataStorm/callbacks/Writer.cpp index d0761d9ec3c..1b3a679a1d5 100644 --- a/cpp/test/DataStorm/callbacks/Writer.cpp +++ b/cpp/test/DataStorm/callbacks/Writer.cpp @@ -19,7 +19,7 @@ main(int argc, char* argv[]) callbackExecutor = [](function cb) { cb(); }; } } - Node node(callbackExecutor, argc, argv); + Node node(argc, argv, nullopt, callbackExecutor); WriterConfig config; config.sampleCount = -1; // Unlimited sample count diff --git a/cpp/test/Ice/properties/Client.cpp b/cpp/test/Ice/properties/Client.cpp index 9a38635745b..edd555aa971 100644 --- a/cpp/test/Ice/properties/Client.cpp +++ b/cpp/test/Ice/properties/Client.cpp @@ -193,6 +193,18 @@ Client::run(int, char**) catch (const Ice::PropertyException&) { } + cout << "ok" << endl; + + cout << "testing that setting a property in a reserved service prefix throws an exception..." << flush; + + try + { + properties->setProperty("IceGrid.InstanceName", "TestGrid"); + test(false); + } + catch (const Ice::PropertyException&) + { + } } } diff --git a/cpp/test/IceBox/configuration/AllTests.cpp b/cpp/test/IceBox/configuration/AllTests.cpp index 07f04a2730a..0189b6234f3 100644 --- a/cpp/test/IceBox/configuration/AllTests.cpp +++ b/cpp/test/IceBox/configuration/AllTests.cpp @@ -18,10 +18,9 @@ allTests(Test::TestHelper* helper) TestIntfPrx service3(com, "test:" + helper->getTestEndpoint(2)); TestIntfPrx service4(com, "test:" + helper->getTestEndpoint(3)); - if (service1->getProperty("IceBox.InheritProperties") == "") + if (service1->getProperty("TestInheritProperties") == "") { cout << "testing service properties... " << flush; - test(service1->getProperty("Ice.ProgramName") == "IceBox-Service1"); test(service1->getProperty("Service") == "1"); test(service1->getProperty("Service1.Ovrd") == "2"); @@ -36,7 +35,6 @@ allTests(Test::TestHelper* helper) test(service2->getProperty("Ice.ProgramName") == "Test"); test(service2->getProperty("Service") == "2"); test(service2->getProperty("Service1.ArgProp") == ""); - test(service2->getProperty("IceBox.InheritProperties") == "1"); Ice::StringSeq args2; args2.push_back("--Service1.ArgProp=1"); diff --git a/cpp/test/IceBox/configuration/config.icebox b/cpp/test/IceBox/configuration/config.icebox index 11a6ef13315..237ebf80e7d 100644 --- a/cpp/test/IceBox/configuration/config.icebox +++ b/cpp/test/IceBox/configuration/config.icebox @@ -3,7 +3,7 @@ Ice.Admin.Endpoints=default -p 9996 -h 127.0.0.1 Ice.ProgramName=IceBox IceBox.Service.Service1=TestService:create --Ice.Config=config.service1 --Service1.ArgProp=1 --Service1.Ovrd=2 --Service1.Unset= -a --Arg=2 -IceBox.Service.Service2=TestService:create --Ice.Config=config.service2 --Service1.ArgProp=1 --IceBox.InheritProperties +IceBox.Service.Service2=TestService:create --Ice.Config=config.service2 --Service1.ArgProp=1 IceBox.UseSharedCommunicator.Service3=1 IceBox.Service.Service3=TestService:create --Ice.Config=config.service3 diff --git a/cpp/test/IceBox/configuration/config.icebox2 b/cpp/test/IceBox/configuration/config.icebox2 index 8521437da6b..56b137cf492 100644 --- a/cpp/test/IceBox/configuration/config.icebox2 +++ b/cpp/test/IceBox/configuration/config.icebox2 @@ -4,6 +4,8 @@ Ice.ProgramName=IceBox2 IceBox.InheritProperties=1 +TestInheritProperties=1 + ServerProp=1 OverrideMe=1 UnsetMe=1 diff --git a/cpp/test/IceStorm/federation/Publisher.cpp b/cpp/test/IceStorm/federation/Publisher.cpp index d149ba9cf7e..f5b1a94b94c 100644 --- a/cpp/test/IceStorm/federation/Publisher.cpp +++ b/cpp/test/IceStorm/federation/Publisher.cpp @@ -21,7 +21,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); Ice::CommunicatorPtr communicator = ich.communicator(); string managerProxy = communicator->getProperties()->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index 3b4791a7156..37dc28d08e4 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -49,7 +49,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); bool batch = false; int idx = 1; diff --git a/cpp/test/IceStorm/federation2/Publisher.cpp b/cpp/test/IceStorm/federation2/Publisher.cpp index 8b462051ae7..f602404d52a 100644 --- a/cpp/test/IceStorm/federation2/Publisher.cpp +++ b/cpp/test/IceStorm/federation2/Publisher.cpp @@ -23,7 +23,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); auto communicator = ich.communicator(); IceInternal::Options opts; opts.addOpt("", "count", IceInternal::Options::NeedArg); diff --git a/cpp/test/IceStorm/federation2/Subscriber.cpp b/cpp/test/IceStorm/federation2/Subscriber.cpp index 3f53a9cdbc9..791960b9c94 100644 --- a/cpp/test/IceStorm/federation2/Subscriber.cpp +++ b/cpp/test/IceStorm/federation2/Subscriber.cpp @@ -63,7 +63,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); bool batch = false; int idx = 1; diff --git a/cpp/test/IceStorm/persistent/Client.cpp b/cpp/test/IceStorm/persistent/Client.cpp index ddb0dd59c03..8bb2e1deba3 100644 --- a/cpp/test/IceStorm/persistent/Client.cpp +++ b/cpp/test/IceStorm/persistent/Client.cpp @@ -22,7 +22,7 @@ class Client final : public Test::TestHelper void Client::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); auto communicator = ich.communicator(); auto properties = communicator->getProperties(); auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); diff --git a/cpp/test/IceStorm/rep1/Publisher.cpp b/cpp/test/IceStorm/rep1/Publisher.cpp index 33ab9f9a05b..e1047197328 100644 --- a/cpp/test/IceStorm/rep1/Publisher.cpp +++ b/cpp/test/IceStorm/rep1/Publisher.cpp @@ -24,7 +24,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); auto communicator = ich.communicator(); IceInternal::Options opts; opts.addOpt("", "cycle"); diff --git a/cpp/test/IceStorm/rep1/Sub.cpp b/cpp/test/IceStorm/rep1/Sub.cpp index 88c57d04281..b30a3e6f6de 100644 --- a/cpp/test/IceStorm/rep1/Sub.cpp +++ b/cpp/test/IceStorm/rep1/Sub.cpp @@ -30,7 +30,7 @@ class Sub final : public Test::TestHelper void Sub::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); IceInternal::Options opts; opts.addOpt("", "id", IceInternal::Options::NeedArg); opts.addOpt("", "unsub"); diff --git a/cpp/test/IceStorm/rep1/Subscriber.cpp b/cpp/test/IceStorm/rep1/Subscriber.cpp index 0148e64b3f9..8b026602f8a 100644 --- a/cpp/test/IceStorm/rep1/Subscriber.cpp +++ b/cpp/test/IceStorm/rep1/Subscriber.cpp @@ -73,7 +73,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); IceInternal::Options opts; opts.addOpt("", "ordered"); opts.addOpt("", "twoway"); diff --git a/cpp/test/IceStorm/repstress/Publisher.cpp b/cpp/test/IceStorm/repstress/Publisher.cpp index 538429f2c74..a08d21c97c0 100644 --- a/cpp/test/IceStorm/repstress/Publisher.cpp +++ b/cpp/test/IceStorm/repstress/Publisher.cpp @@ -76,7 +76,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); auto communicator = ich.communicator(); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); diff --git a/cpp/test/IceStorm/repstress/Subscriber.cpp b/cpp/test/IceStorm/repstress/Subscriber.cpp index e59a39f449b..d89d3acbaaf 100644 --- a/cpp/test/IceStorm/repstress/Subscriber.cpp +++ b/cpp/test/IceStorm/repstress/Subscriber.cpp @@ -41,7 +41,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/single/Publisher.cpp b/cpp/test/IceStorm/single/Publisher.cpp index ae9733e3094..0cc879d2a72 100644 --- a/cpp/test/IceStorm/single/Publisher.cpp +++ b/cpp/test/IceStorm/single/Publisher.cpp @@ -23,7 +23,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index 5b1c2c111ff..9c8e14c4a84 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -106,7 +106,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/stress/Publisher.cpp b/cpp/test/IceStorm/stress/Publisher.cpp index b7ca21010c5..44d331d59cb 100644 --- a/cpp/test/IceStorm/stress/Publisher.cpp +++ b/cpp/test/IceStorm/stress/Publisher.cpp @@ -25,7 +25,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); IceInternal::Options opts; opts.addOpt("", "events", IceInternal::Options::NeedArg); opts.addOpt("", "oneway"); diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index c9a4990a342..57199e05c1d 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -239,7 +239,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); auto communicator = ich.communicator(); IceInternal::Options opts; opts.addOpt("", "events", IceInternal::Options::NeedArg); diff --git a/csharp/src/Ice/Internal/PropertyNames.cs b/csharp/src/Ice/Internal/PropertyNames.cs index 3f4076a281c..20687886313 100644 --- a/csharp/src/Ice/Internal/PropertyNames.cs +++ b/csharp/src/Ice/Internal/PropertyNames.cs @@ -155,6 +155,18 @@ internal sealed class PropertyNames new(pattern: @"CacheMessageBuffers", usesRegex: false, defaultValue: "2", deprecated: false, propertyArray: null) ]); + internal static PropertyArray IceMXProps = new( + "IceMX", + false, + [ + new(pattern: @"^Metrics\.[^\s]+\.GroupBy$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), + new(pattern: @"^Metrics\.[^\s]+\.Map$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), + new(pattern: @"^Metrics\.[^\s]+\.RetainDetached$", usesRegex: true, defaultValue: "10", deprecated: false, propertyArray: null), + new(pattern: @"^Metrics\.[^\s]+\.Accept$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), + new(pattern: @"^Metrics\.[^\s]+\.Reject$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), + new(pattern: @"^Metrics\.[^\s]+$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null) + ]); + internal static PropertyArray IceDiscoveryProps = new( "IceDiscovery", false, @@ -271,6 +283,7 @@ internal sealed class PropertyNames internal static PropertyArray[] validProps = [ IceProps, + IceMXProps, IceDiscoveryProps, IceLocatorDiscoveryProps, IceBoxProps, diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java index ed30ae9377d..419bb618a7b 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java @@ -2,6 +2,9 @@ package com.zeroc.Ice; +import com.zeroc.Ice.Instrumentation.CommunicatorObserver; +import com.zeroc.Ice.SSL.SSLEngineFactory; + import java.net.InetAddress; import java.util.ArrayList; import java.util.List; @@ -9,9 +12,6 @@ import java.util.Stack; import java.util.function.Function; -import com.zeroc.Ice.Instrumentation.CommunicatorObserver; -import com.zeroc.Ice.SSL.SSLEngineFactory; - /** * The object adapter provides an up-call interface from the Ice run time to the implementation of * Ice objects. The object adapter is responsible for receiving requests from endpoints, and for diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java b/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java index 750b8bec509..c69380e0492 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java @@ -160,6 +160,18 @@ final class PropertyNames new Property("ThreadInterruptSafe", false, "", false, null) }); + public static final PropertyArray IceMXProps = new PropertyArray( + "IceMX", + false, + new Property[] { + new Property("Metrics\\.[^\\s]+\\.GroupBy", true, "", false, null), + new Property("Metrics\\.[^\\s]+\\.Map", true, "", false, null), + new Property("Metrics\\.[^\\s]+\\.RetainDetached", true, "10", false, null), + new Property("Metrics\\.[^\\s]+\\.Accept", true, "", false, null), + new Property("Metrics\\.[^\\s]+\\.Reject", true, "", false, null), + new Property("Metrics\\.[^\\s]+", true, "", false, null) + }); + public static final PropertyArray IceDiscoveryProps = new PropertyArray( "IceDiscovery", false, @@ -292,6 +304,7 @@ final class PropertyNames public static final PropertyArray validProps[] = { IceProps, + IceMXProps, IceDiscoveryProps, IceLocatorDiscoveryProps, IceBoxProps, diff --git a/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java b/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java index 070000637d9..0e0b91dea79 100644 --- a/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java @@ -409,7 +409,7 @@ private synchronized void start( info.status = StatusStopped; info.args = args; - // If Ice.UseSharedCommunicator. is defined, create a + // If IceBox.UseSharedCommunicator. is defined, create a // communicator for the service. The communicator inherits // from the shared communicator properties. If it's not // defined, add the service properties to the shared @@ -522,7 +522,8 @@ private synchronized void start( obj = c.getDeclaredConstructor().newInstance(); } catch (IllegalAccessException ex) { throw new FailureException( - "ServiceManager: unable to access default service constructor in class " + "ServiceManager: unable to access default service constructor in" + + " class " + className, ex); } diff --git a/js/src/Ice/PropertyNames.js b/js/src/Ice/PropertyNames.js index 0033e6b2035..eaa1bca3e8c 100644 --- a/js/src/Ice/PropertyNames.js +++ b/js/src/Ice/PropertyNames.js @@ -79,6 +79,10 @@ PropertyNames.IceProps.properties = [ new Property("Warn.UnusedProperties", false, "0", false, null) ]; +PropertyNames.IceMXProps = new PropertyArray("IceMX", false); +PropertyNames.IceMXProps.properties = [ +]; + PropertyNames.IceDiscoveryProps = new PropertyArray("IceDiscovery", false); PropertyNames.IceDiscoveryProps.properties = [ ]; @@ -133,6 +137,7 @@ PropertyNames.DataStormProps.properties = [ PropertyNames.validProps = [ PropertyNames.IceProps, + PropertyNames.IceMXProps, PropertyNames.IceDiscoveryProps, PropertyNames.IceLocatorDiscoveryProps, PropertyNames.IceBoxProps, diff --git a/scripts/IceStormUtil.py b/scripts/IceStormUtil.py index f75dc5818db..ad734d26895 100644 --- a/scripts/IceStormUtil.py +++ b/scripts/IceStormUtil.py @@ -213,9 +213,9 @@ def getProps(self, current): ) else: for name in instanceNames: - props[ - "IceStormAdmin.TopicManager.{0}".format(name) - ] = testcase.getTopicManager(current, name) + props["IceStormAdmin.TopicManager.{0}".format(name)] = ( + testcase.getTopicManager(current, name) + ) return props From f0ba1d2a3c2d3d6157837ac405f4ec5cf36f8333 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 28 Oct 2024 11:22:06 -0400 Subject: [PATCH 03/10] Build fixes --- cpp/src/DataStorm/Node.cpp | 15 ++++++++--- cpp/src/Glacier2/Glacier2Router.cpp | 4 ++- cpp/src/IceBox/Admin.cpp | 4 ++- cpp/src/IceBox/ServiceManagerI.cpp | 2 +- cpp/src/IceBridge/IceBridge.cpp | 4 ++- cpp/src/IceGrid/IceGridNode.cpp | 4 ++- cpp/src/IceGrid/IceGridRegistry.cpp | 4 ++- cpp/test/DataStorm/api/Writer.cpp | 26 ++++++++++++------- .../com/zeroc/IceBox/ServiceManagerI.java | 2 +- 9 files changed, 46 insertions(+), 19 deletions(-) diff --git a/cpp/src/DataStorm/Node.cpp b/cpp/src/DataStorm/Node.cpp index 2cbaa14f167..73f6454c01f 100644 --- a/cpp/src/DataStorm/Node.cpp +++ b/cpp/src/DataStorm/Node.cpp @@ -23,7 +23,10 @@ namespace properties->load(*configFile); } - return Ice::initialize(argc, argv, {.properties = properties}); + Ice::InitializationData initData; + initData.properties = properties; + + return Ice::initialize(argc, argv, initData); } #ifdef _WIN32 @@ -36,7 +39,10 @@ namespace properties->load(*configFile); } - return Ice::initialize(argc, argv, {.properties = properties}); + Ice::InitializationData initData; + initData.properties = properties; + + return Ice::initialize(argc, argv, initData); } #endif @@ -49,7 +55,10 @@ namespace properties->load(*configFile); } - return Ice::initialize({.properties = properties}); + Ice::InitializationData initData; + initData.properties = properties; + + return Ice::initialize(initData); } } diff --git a/cpp/src/Glacier2/Glacier2Router.cpp b/cpp/src/Glacier2/Glacier2Router.cpp index 270093c035e..2cf2d708b09 100644 --- a/cpp/src/Glacier2/Glacier2Router.cpp +++ b/cpp/src/Glacier2/Glacier2Router.cpp @@ -491,5 +491,7 @@ main(int argc, char* argv[]) { RouterService svc; // Initialize the service with a Properties object with the correct property prefix enabled. - return svc.main(argc, argv, {.properties = make_shared("Glacier2")}); + Ice::InitializationData initData; + initData.properties = make_shared("Glacier2"); + return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp index 370542cac0a..e43d0ac400f 100644 --- a/cpp/src/IceBox/Admin.cpp +++ b/cpp/src/IceBox/Admin.cpp @@ -34,7 +34,9 @@ main(int argc, char* argv[]) Ice::CtrlCHandler ctrlCHandler; // Initialize with a Properties object with the correct property prefix enabled. - Ice::InitializationData initData{.properties = make_shared("IceBoxAdmin")}; + Ice::InitializationData initData; + initData.properties = make_shared("IceBoxAdmin"); + Ice::CommunicatorHolder ich{argc, argv, initData}; communicator = ich.communicator(); diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index fb520475eae..1da46816d13 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -29,7 +29,7 @@ namespace // // Split the entire property value into arguments. An entry point containing spaces // must be enclosed in quotes. - // p + // try { args = IceInternal::Options::split(value); diff --git a/cpp/src/IceBridge/IceBridge.cpp b/cpp/src/IceBridge/IceBridge.cpp index c46353a2dc9..04b9d6aa1ef 100644 --- a/cpp/src/IceBridge/IceBridge.cpp +++ b/cpp/src/IceBridge/IceBridge.cpp @@ -630,5 +630,7 @@ main(int argc, char* argv[]) { BridgeService svc; // Initialize the service with a Properties object with the correct property prefix enabled. - return svc.main(argc, argv, {.properties = make_shared("IceBridge")}); + Ice::InitializationData initData; + initData.properties = make_shared("IceBridge"); + return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 8df19b75847..2bdf1291018 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -814,5 +814,7 @@ main(int argc, char* argv[]) { NodeService svc; // Initialize the service with a Properties object with the correct property prefix enabled. - return svc.main(argc, argv, {.properties = make_shared("IceGrid")}); + Ice::InitializationData initData; + initData.properties = make_shared("IceGrid"); + return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index 7d57af16a4f..63322eb2292 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -240,5 +240,7 @@ main(int argc, char* argv[]) { RegistryService svc; // Initialize the service with a Properties object with the correct property prefix enabled. - return svc.main(argc, argv, {.properties = make_shared("IceGrid")}); + Ice::InitializationData initData; + initData.properties = make_shared("IceGrid"); + return svc.main(argc, argv, initData); } diff --git a/cpp/test/DataStorm/api/Writer.cpp b/cpp/test/DataStorm/api/Writer.cpp index b8203669965..7eef2b163c2 100644 --- a/cpp/test/DataStorm/api/Writer.cpp +++ b/cpp/test/DataStorm/api/Writer.cpp @@ -18,17 +18,25 @@ main(int argc, char* argv[]) cout << "testing node..." << flush; { - Node n; - Node nm(std::move(n)); - auto nm2 = std::move(nm); - nm2.getCommunicator(); - nm2.getSessionConnection("s"); + { + Node n; + Node nm(std::move(n)); + auto nm2 = std::move(nm); + nm2.getCommunicator(); + nm2.getSessionConnection("s"); + } - // Communicators shared with DataStorm must have a property set that can use the "DataStorm" service prefix. - Node n2(Ice::initialize({.properties = make_shared("DataStorm")})); - n2.getCommunicator()->destroy(); + { + // Communicators shared with DataStorm must have a property set that can use the "DataStorm" service prefix. + Ice::InitializationData initData; + initData.properties = make_shared("DataStorm"); + Node n2(Ice::initialize(initData)); + n2.getCommunicator()->destroy(); + } - auto c = Ice::initialize({.properties = make_shared("DataStorm")}); + Ice::InitializationData initData; + initData.properties = make_shared("DataStorm"); + auto c = Ice::initialize(initData); { Node n22(c); } diff --git a/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java b/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java index 0e0b91dea79..89c73a69c11 100644 --- a/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java @@ -523,7 +523,7 @@ private synchronized void start( } catch (IllegalAccessException ex) { throw new FailureException( "ServiceManager: unable to access default service constructor in" - + " class " + + " class " + className, ex); } From 79ce92c0576bc7b213a2de1087f77f7722b3bbf1 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 28 Oct 2024 13:31:06 -0400 Subject: [PATCH 04/10] Rename UnknownPropertyException --- cpp/include/Ice/LocalExceptions.h | 4 ++-- cpp/src/Ice/PropertyUtil.h | 2 +- cpp/test/Ice/properties/Client.cpp | 2 +- csharp/src/Ice/Internal/MetricsAdminI.cs | 2 +- csharp/src/Ice/LocalExceptions.cs | 11 ++++++----- csharp/src/Ice/Properties.cs | 10 +++++----- csharp/test/Ice/properties/Client.cs | 8 ++++---- .../java/com/zeroc/Ice/MetricsAdminI.java | 2 +- .../java/com/zeroc/Ice/ObjectAdapter.java | 2 +- .../main/java/com/zeroc/Ice/Properties.java | 12 ++++++------ .../java/com/zeroc/Ice/PropertyException.java | 19 +++++++++++++++++++ .../zeroc/Ice/UnknownPropertyException.java | 16 ---------------- .../main/java/test/Ice/properties/Client.java | 16 +++++++++------- js/src/Ice/LocalExceptions.d.ts | 5 +++-- js/src/Ice/LocalExceptions.js | 4 ++-- js/src/Ice/Properties.js | 10 +++++----- js/test/Ice/exceptions/Client.ts | 2 +- js/test/Ice/properties/Client.ts | 8 ++++---- matlab/lib/+Ice/PropertyException.m | 9 +++++++++ matlab/lib/+Ice/UnknownPropertyException.m | 8 -------- matlab/test/Ice/properties/Client.m | 2 +- php/lib/Ice/LocalExceptions.php | 2 +- php/test/Ice/properties/Client.php | 2 +- python/python/Ice/LocalExceptions.py | 7 ++++--- python/test/Ice/properties/Client.py | 2 +- ruby/ruby/Ice/LocalExceptions.rb | 2 +- ruby/test/Ice/properties/Client.rb | 2 +- swift/src/Ice/LocalExceptions.swift | 4 ++-- swift/src/IceImpl/Properties.mm | 2 +- swift/test/Ice/properties/Client.swift | 4 ++-- 30 files changed, 95 insertions(+), 86 deletions(-) create mode 100644 java/src/Ice/src/main/java/com/zeroc/Ice/PropertyException.java delete mode 100644 java/src/Ice/src/main/java/com/zeroc/Ice/UnknownPropertyException.java create mode 100644 matlab/lib/+Ice/PropertyException.m delete mode 100644 matlab/lib/+Ice/UnknownPropertyException.m diff --git a/cpp/include/Ice/LocalExceptions.h b/cpp/include/Ice/LocalExceptions.h index 69766fb18a0..11c817e2082 100644 --- a/cpp/include/Ice/LocalExceptions.h +++ b/cpp/include/Ice/LocalExceptions.h @@ -934,8 +934,8 @@ namespace Ice }; /** - * This exception is raised during the getting or setting of an Ice property. For example, this can happen when - * trying to set an unknown property or when the property value is invalid. + * This exception is raised when there is an error while getting or setting a property. For example, when + * trying to set an unknown Ice property. */ class ICE_API PropertyException final : public LocalException { diff --git a/cpp/src/Ice/PropertyUtil.h b/cpp/src/Ice/PropertyUtil.h index 55601e3efb9..62d4b774c08 100644 --- a/cpp/src/Ice/PropertyUtil.h +++ b/cpp/src/Ice/PropertyUtil.h @@ -21,7 +21,7 @@ namespace IceInternal /// @param prefix The prefix to validate. /// @param properties The properties to consider. /// @param propertyArray The property array to search against. - /// @throws UnknownPropertyException if unknown properties are found. + /// @throws PropertyException if unknown properties are found. void validatePropertiesWithPrefix( std::string_view prefix, const Ice::PropertiesPtr& properties, diff --git a/cpp/test/Ice/properties/Client.cpp b/cpp/test/Ice/properties/Client.cpp index edd555aa971..6b99012055f 100644 --- a/cpp/test/Ice/properties/Client.cpp +++ b/cpp/test/Ice/properties/Client.cpp @@ -196,7 +196,6 @@ Client::run(int, char**) cout << "ok" << endl; cout << "testing that setting a property in a reserved service prefix throws an exception..." << flush; - try { properties->setProperty("IceGrid.InstanceName", "TestGrid"); @@ -205,6 +204,7 @@ Client::run(int, char**) catch (const Ice::PropertyException&) { } + cout << "ok" << endl; } } diff --git a/csharp/src/Ice/Internal/MetricsAdminI.cs b/csharp/src/Ice/Internal/MetricsAdminI.cs index f753580e184..1e5bf5a2e79 100644 --- a/csharp/src/Ice/Internal/MetricsAdminI.cs +++ b/csharp/src/Ice/Internal/MetricsAdminI.cs @@ -700,7 +700,7 @@ public static void validateProperties(string prefix, Ice.Properties properties) message.Append("\n "); message.Append(p); } - throw new UnknownPropertyException(message.ToString()); + throw new PropertyException(message.ToString()); } } diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index ee74c6d20b4..53532f07d35 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -875,20 +875,21 @@ public TwowayOnlyException(string operation) } /// -/// An unknown property was used when trying to get or set an unknown property. +/// This exception is raised when there is an error while getting or setting a property. For example, when +/// trying to set an unknown Ice property. /// -public sealed class UnknownPropertyException : LocalException +public sealed class PropertyException : LocalException { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The exception message. /// The inner exception. - public UnknownPropertyException(string message, System.Exception? innerException = null) + public PropertyException(string message, System.Exception? innerException = null) : base(message, innerException) { } /// - public override string ice_id() => "::Ice::UnknownPropertyException"; + public override string ice_id() => "::Ice::PropertyException"; } diff --git a/csharp/src/Ice/Properties.cs b/csharp/src/Ice/Properties.cs index d7802993bab..365d0f919f9 100644 --- a/csharp/src/Ice/Properties.cs +++ b/csharp/src/Ice/Properties.cs @@ -324,7 +324,7 @@ public void setProperty(string key, string value) // Check if the property is in an Ice property prefix. If so, check that it's a valid property. if (findIcePropertyArray(key) is PropertyArray propertyArray) { - Property prop = findProperty(key[(propertyArray.name.Length + 1)..], propertyArray) ?? throw new UnknownPropertyException($"unknown Ice property: {key}"); + Property prop = findProperty(key[(propertyArray.name.Length + 1)..], propertyArray) ?? throw new PropertyException($"unknown Ice property: {key}"); // If the property is deprecated, log a warning. if (prop.deprecated) @@ -504,7 +504,7 @@ public List getUnusedProperties() /// The property prefix to validate. /// The properties to consider. /// The property array to search against. - /// Thrown if unknown properties are found. + /// Thrown if unknown properties are found. internal static void validatePropertiesWithPrefix(string prefix, Properties properties, PropertyArray propertyArray) { // Do not check for unknown properties if Ice prefix, ie Ice, Glacier2, etc @@ -537,7 +537,7 @@ internal static void validatePropertiesWithPrefix(string prefix, Properties prop message.Append(s); } - throw new UnknownPropertyException(message.ToString()); + throw new PropertyException(message.ToString()); } } @@ -622,10 +622,10 @@ internal static void validatePropertiesWithPrefix(string prefix, Properties prop private static string getDefaultProperty(string key) { // Find the property, don't log any warnings. - PropertyArray propertyArray = findIcePropertyArray(key) ?? throw new UnknownPropertyException($"unknown Ice property: {key}"); + PropertyArray propertyArray = findIcePropertyArray(key) ?? throw new PropertyException($"unknown Ice property: {key}"); // Find the property in the property array. - Property prop = findProperty(key[(propertyArray.name.Length + 1)..], propertyArray) ?? throw new UnknownPropertyException($"unknown Ice property: {key}"); + Property prop = findProperty(key[(propertyArray.name.Length + 1)..], propertyArray) ?? throw new PropertyException($"unknown Ice property: {key}"); return prop.defaultValue; } diff --git a/csharp/test/Ice/properties/Client.cs b/csharp/test/Ice/properties/Client.cs index d7a28465b3b..c699b211711 100644 --- a/csharp/test/Ice/properties/Client.cs +++ b/csharp/test/Ice/properties/Client.cs @@ -113,7 +113,7 @@ public override void run(string[] args) properties.getIceProperty("Ice.UnknownProperty"); test(false); } - catch (Ice.UnknownPropertyException) + catch (Ice.PropertyException) { } Console.Out.WriteLine("ok"); @@ -128,7 +128,7 @@ public override void run(string[] args) properties.setProperty("Ice.UnknownProperty", "bar"); test(false); } - catch (Ice.UnknownPropertyException) + catch (Ice.PropertyException) { } Console.Out.WriteLine("ok"); @@ -146,7 +146,7 @@ public override void run(string[] args) communicator.createObjectAdapter("FooOA"); test(false); } - catch (Ice.UnknownPropertyException) + catch (Ice.PropertyException) { } Console.Out.WriteLine("ok"); @@ -159,7 +159,7 @@ public override void run(string[] args) communicator.propertyToProxy("FooProxy"); test(false); } - catch (Ice.UnknownPropertyException) + catch (Ice.PropertyException) { } diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/MetricsAdminI.java b/java/src/Ice/src/main/java/com/zeroc/Ice/MetricsAdminI.java index 28be57850c8..c7d02d643c1 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/MetricsAdminI.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/MetricsAdminI.java @@ -36,7 +36,7 @@ static void validateProperties(String prefix, Properties properties) { } if (unknownProps.size() > 0) { - throw new UnknownPropertyException( + throw new PropertyException( "found unknown IceMX properties for:" + ": '" + prefix diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java index 419bb618a7b..1f6f516ba01 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java @@ -1093,7 +1093,7 @@ public int messageSizeMax() { try { Properties.validatePropertiesWithPrefix( _name, properties, PropertyNames.ObjectAdapterProps); - } catch (UnknownPropertyException ex) { + } catch (PropertyException ex) { // Prevent finalizer from complaining about the adapter not being destroyed. _state = StateDestroyed; throw ex; diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/Properties.java b/java/src/Ice/src/main/java/com/zeroc/Ice/Properties.java index e8964dcfdc1..b78d79b028c 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/Properties.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/Properties.java @@ -364,7 +364,7 @@ public void setProperty(String key, String value) { Property prop = findProperty(key.substring(propertyArray.name().length() + 1), propertyArray); if (prop == null) { - throw new UnknownPropertyException("unknown Ice property: " + key); + throw new PropertyException("unknown Ice property: " + key); } // If the property is deprecated, log a warning if (prop.deprecated()) { @@ -829,7 +829,7 @@ static Property findProperty(String key, PropertyArray propertyArray) { * @param prefix The property prefix. * @param properties The properties to validate. * @param propertyArray The property array to validate against. - * @throws UnknownPropertyException if any unknown properties are found. + * @throws PropertyException if any unknown properties are found. */ static void validatePropertiesWithPrefix( String prefix, Properties properties, PropertyArray propertyArray) { @@ -851,7 +851,7 @@ static void validatePropertiesWithPrefix( .collect(Collectors.toList()); if (unknownProperties.size() > 0) { - throw new UnknownPropertyException( + throw new PropertyException( "found unknown properties for " + propertyArray.name() + ": '" @@ -886,18 +886,18 @@ private static PropertyArray findIcePropertyArray(String key) { * Gets the default value for a given Ice property. * @param key The property key. * @return The default value. - * @throws UnknownPropertyException if the property is unknown. + * @throws PropertyException if the property is unknown. */ private static String getDefaultProperty(String key) { PropertyArray propertyArray = findIcePropertyArray(key); if (propertyArray == null) { - throw new UnknownPropertyException("unknown Ice property: " + key); + throw new PropertyException("unknown Ice property: " + key); } Property prop = findProperty(key.substring(propertyArray.name().length() + 1), propertyArray); if (prop == null) { - throw new UnknownPropertyException("unknown Ice property: " + key); + throw new PropertyException("unknown Ice property: " + key); } return prop.defaultValue(); } diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyException.java b/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyException.java new file mode 100644 index 00000000000..6a37d91204a --- /dev/null +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/PropertyException.java @@ -0,0 +1,19 @@ +// Copyright (c) ZeroC, Inc. + +package com.zeroc.Ice; + +/** + * This exception is raised when there is an error while getting or setting a property. For example, + * when trying to set an unknown Ice property. + */ +public final class PropertyException extends LocalException { + private static final long serialVersionUID = 3503752114859671311L; + + public PropertyException(String message) { + super(message); + } + + public String ice_id() { + return "::Ice::PropertyException"; + } +} diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/UnknownPropertyException.java b/java/src/Ice/src/main/java/com/zeroc/Ice/UnknownPropertyException.java deleted file mode 100644 index d5db3b3fd82..00000000000 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/UnknownPropertyException.java +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) ZeroC, Inc. - -package com.zeroc.Ice; - -/** An unknown property was used when trying to get or set an unknown property. */ -public final class UnknownPropertyException extends LocalException { - private static final long serialVersionUID = 3503752114859671311L; - - public UnknownPropertyException(String message) { - super(message); - } - - public String ice_id() { - return "::Ice::UnknownPropertyException"; - } -} diff --git a/java/test/src/main/java/test/Ice/properties/Client.java b/java/test/src/main/java/test/Ice/properties/Client.java index d57e76c6150..9f45ce4a9f7 100644 --- a/java/test/src/main/java/test/Ice/properties/Client.java +++ b/java/test/src/main/java/test/Ice/properties/Client.java @@ -5,7 +5,7 @@ package test.Ice.properties; import com.zeroc.Ice.Properties; -import com.zeroc.Ice.UnknownPropertyException; +import com.zeroc.Ice.PropertyException; import com.zeroc.Ice.Util; public class Client extends test.TestHelper { @@ -117,7 +117,7 @@ public void run(String[] args) { try { properties.getIceProperty("Ice.UnknownProperty"); test(false); - } catch (UnknownPropertyException ex) { + } catch (PropertyException ex) { } System.out.println("ok"); } @@ -128,7 +128,7 @@ public void run(String[] args) { try { properties.setProperty("Ice.UnknownProperty", "bar"); test(false); - } catch (UnknownPropertyException ex) { + } catch (PropertyException ex) { } System.out.println("ok"); } @@ -138,24 +138,26 @@ public void run(String[] args) { var properties = communicator.getProperties(); System.out.print( - "testing that creating an object adapter with unknown properties throws an exception..."); + "testing that creating an object adapter with unknown properties throws an" + + " exception..."); properties.setProperty("FooOA.Endpoints", "tcp -h 127.0.0.1"); properties.setProperty("FooOA.UnknownProperty", "bar"); try { communicator.createObjectAdapter("FooOA"); test(false); - } catch (UnknownPropertyException ex) { + } catch (PropertyException ex) { } System.out.println("ok"); System.out.print( - "testing that creating a proxy with unknown properties throws an exception..."); + "testing that creating a proxy with unknown properties throws an" + + " exception..."); properties.setProperty("FooProxy", "test:tcp -h 127.0.0.1 -p 10000"); properties.setProperty("FooProxy.UnknownProperty", "bar"); try { communicator.propertyToProxy("FooProxy"); test(false); - } catch (UnknownPropertyException ex) { + } catch (PropertyException ex) { } System.out.println("ok"); } diff --git a/js/src/Ice/LocalExceptions.d.ts b/js/src/Ice/LocalExceptions.d.ts index dd9d2e07266..c3f38936469 100644 --- a/js/src/Ice/LocalExceptions.d.ts +++ b/js/src/Ice/LocalExceptions.d.ts @@ -260,9 +260,10 @@ declare module "ice" { } /** - * An unknown property was used when trying to get or set an unknown property. + * This exception is raised when there is an error while getting or setting a property. For example, when + * trying to set an unknown Ice property. */ - class UnknownPropertyException extends LocalException { + class PropertyException extends LocalException { constructor(message: string); } } diff --git a/js/src/Ice/LocalExceptions.js b/js/src/Ice/LocalExceptions.js index 9c6dd067db3..a89571601b8 100644 --- a/js/src/Ice/LocalExceptions.js +++ b/js/src/Ice/LocalExceptions.js @@ -353,9 +353,9 @@ export class TwowayOnlyException extends LocalException { } } -export class UnknownPropertyException extends LocalException { +export class PropertyException extends LocalException { static get _ice_id() { - return "::Ice::UnknownPropertyException"; + return "::Ice::PropertyException"; } constructor(message) { diff --git a/js/src/Ice/Properties.js b/js/src/Ice/Properties.js index 9a31455b1de..271e39d7132 100644 --- a/js/src/Ice/Properties.js +++ b/js/src/Ice/Properties.js @@ -6,7 +6,7 @@ import { StringUtil } from "./StringUtil.js"; import { PropertyNames } from "./PropertyNames.js"; import { getProcessLogger } from "./ProcessLogger.js"; import { InitializationException } from "./LocalExceptions.js"; -import { UnknownPropertyException } from "./LocalExceptions.js"; +import { PropertyException } from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; const ParseStateKey = 0; @@ -142,7 +142,7 @@ export class Properties { const prop = Properties.findProperty(key.substring(propertyArray.name.length + 1), propertyArray); if (prop === null) { - throw new UnknownPropertyException(`unknown Ice property: ${key}`); + throw new PropertyException(`unknown Ice property: ${key}`); } // If the property is deprecated, log a warning @@ -424,7 +424,7 @@ export class Properties { ); if (unknownProps.length > 0) { - throw new UnknownPropertyException( + throw new PropertyException( `found unknown properties for ${propertyArray.name}: '${prefix}'\n ${unknownProps.join("\n ")}`, ); } @@ -447,12 +447,12 @@ export class Properties { static getDefaultProperty(key) { const propertyArray = Properties.findIcePropertyArray(key); if (!propertyArray) { - throw new UnknownPropertyException(`unknown Ice property: ${key}`); + throw new PropertyException(`unknown Ice property: ${key}`); } const prop = Properties.findProperty(key.substring(propertyArray.name.length + 1), propertyArray); if (!prop) { - throw new UnknownPropertyException(`unknown Ice property: ${key}`); + throw new PropertyException(`unknown Ice property: ${key}`); } return prop.defaultValue; diff --git a/js/test/Ice/exceptions/Client.ts b/js/test/Ice/exceptions/Client.ts index 0e10c294f67..e69b1200730 100644 --- a/js/test/Ice/exceptions/Client.ts +++ b/js/test/Ice/exceptions/Client.ts @@ -37,7 +37,7 @@ export class Client extends TestHelper { await communicator.createObjectAdapter("TestAdapter0"); test(false); } catch (ex) { - test(ex instanceof Ice.UnknownPropertyException, ex); // Expected + test(ex instanceof Ice.PropertyException, ex); // Expected } out.writeLine("ok"); diff --git a/js/test/Ice/properties/Client.ts b/js/test/Ice/properties/Client.ts index 812cb305707..bb91d10b741 100644 --- a/js/test/Ice/properties/Client.ts +++ b/js/test/Ice/properties/Client.ts @@ -102,7 +102,7 @@ export class Client extends TestHelper { properties.getIceProperty("Ice.UnknownProperty"); test(false); } catch (ex) { - test(ex instanceof Ice.UnknownPropertyException); + test(ex instanceof Ice.PropertyException); } out.writeLine("ok"); } @@ -114,7 +114,7 @@ export class Client extends TestHelper { properties.setProperty("Ice.UnknownProperty", "bar"); test(false); } catch (ex) { - test(ex instanceof Ice.UnknownPropertyException); + test(ex instanceof Ice.PropertyException); } out.writeLine("ok"); } @@ -130,7 +130,7 @@ export class Client extends TestHelper { await communicator.createObjectAdapter("FooOA"); test(false); } catch (ex) { - test(ex instanceof Ice.UnknownPropertyException); + test(ex instanceof Ice.PropertyException); } out.writeLine("ok"); @@ -141,7 +141,7 @@ export class Client extends TestHelper { communicator.propertyToProxy("FooProxy"); test(false); } catch (ex) { - test(ex instanceof Ice.UnknownPropertyException); + test(ex instanceof Ice.PropertyException); } out.writeLine("ok"); diff --git a/matlab/lib/+Ice/PropertyException.m b/matlab/lib/+Ice/PropertyException.m new file mode 100644 index 00000000000..6f3ec9f7b62 --- /dev/null +++ b/matlab/lib/+Ice/PropertyException.m @@ -0,0 +1,9 @@ +% PropertyException Summary of PropertyException +% +% This exception is raised when there is an error while getting or setting a property. For example, when +% trying to set an unknown Ice property. + +% Copyright (c) ZeroC, Inc. All rights reserved. + +classdef (Sealed) PropertyException < Ice.LocalException +end diff --git a/matlab/lib/+Ice/UnknownPropertyException.m b/matlab/lib/+Ice/UnknownPropertyException.m deleted file mode 100644 index 33a9ae057b2..00000000000 --- a/matlab/lib/+Ice/UnknownPropertyException.m +++ /dev/null @@ -1,8 +0,0 @@ -% UnknownPropertyException Summary of UnknownPropertyException -% -% An unknown property was used when trying to get or set an unknown property. - -% Copyright (c) ZeroC, Inc. All rights reserved. - -classdef (Sealed) UnknownPropertyException < Ice.LocalException -end diff --git a/matlab/test/Ice/properties/Client.m b/matlab/test/Ice/properties/Client.m index ec8d1ba9e98..b9da71365b7 100644 --- a/matlab/test/Ice/properties/Client.m +++ b/matlab/test/Ice/properties/Client.m @@ -45,7 +45,7 @@ function client(args) props.getIceProperty('Ice.UnknownProperty'); assert(false); catch ex - assert(isa(ex, 'Ice.UnknownPropertyException')); + assert(isa(ex, 'Ice.PropertyException')); end fprintf('ok\n'); diff --git a/php/lib/Ice/LocalExceptions.php b/php/lib/Ice/LocalExceptions.php index a661e54f400..924749aa74b 100644 --- a/php/lib/Ice/LocalExceptions.php +++ b/php/lib/Ice/LocalExceptions.php @@ -116,4 +116,4 @@ final class SecurityException extends LocalException {} final class TwowayOnlyException extends LocalException {} -final class UnknownPropertyException extends LocalException {} +final class PropertyException extends LocalException {} diff --git a/php/test/Ice/properties/Client.php b/php/test/Ice/properties/Client.php index 54f1152c4d0..76115016ec4 100644 --- a/php/test/Ice/properties/Client.php +++ b/php/test/Ice/properties/Client.php @@ -66,7 +66,7 @@ function run($args) $properties = Ice\createProperties(); $properties->getIceProperty("Ice.UnknownProperty"); test(False); - } catch (\Ice\UnknownPropertyException $ex) { + } catch (\Ice\PropertyException $ex) { test($ex->getMessage() == "unknown Ice property: Ice.UnknownProperty"); } echo "ok\n"; diff --git a/python/python/Ice/LocalExceptions.py b/python/python/Ice/LocalExceptions.py index 672e294668a..d901f77f273 100644 --- a/python/python/Ice/LocalExceptions.py +++ b/python/python/Ice/LocalExceptions.py @@ -456,9 +456,10 @@ class TwowayOnlyException(LocalException): @final -class UnknownPropertyException(LocalException): +class PropertyException(LocalException): """ - An unknown property was used when trying to get or set an unknown property. + This exception is raised when there is an error while getting or setting a property. For example, when + trying to set an unknown Ice property. """ @@ -500,5 +501,5 @@ class UnknownPropertyException(LocalException): "ParseException", "SecurityException", "TwowayOnlyException", - "UnknownPropertyException", + "PropertyException", ] diff --git a/python/test/Ice/properties/Client.py b/python/test/Ice/properties/Client.py index 2066e1e5742..d78184518a5 100644 --- a/python/test/Ice/properties/Client.py +++ b/python/test/Ice/properties/Client.py @@ -118,6 +118,6 @@ def run(sef, args): properties = Ice.createProperties() properties.getIceProperty("Ice.UnknownProperty") test(False) - except Ice.UnknownPropertyException: + except Ice.PropertyException: pass print("ok") diff --git a/ruby/ruby/Ice/LocalExceptions.rb b/ruby/ruby/Ice/LocalExceptions.rb index 3469f8eeec6..1197c9c7a3f 100644 --- a/ruby/ruby/Ice/LocalExceptions.rb +++ b/ruby/ruby/Ice/LocalExceptions.rb @@ -158,6 +158,6 @@ class SecurityException < LocalException class TwowayOnlyException < LocalException end - class UnknownPropertyException < LocalException + class PropertyException < LocalException end end diff --git a/ruby/test/Ice/properties/Client.rb b/ruby/test/Ice/properties/Client.rb index 32c7d0962b5..8916042f282 100644 --- a/ruby/test/Ice/properties/Client.rb +++ b/ruby/test/Ice/properties/Client.rb @@ -96,7 +96,7 @@ def run(args) properties = Ice.createProperties(args) properties.getIceProperty("Ice.UnknownProperty") test(false) - rescue Ice::UnknownPropertyException => ex + rescue Ice::PropertyException => ex test(ex.message["unknown Ice property: Ice.UnknownProperty"]) end puts "ok" diff --git a/swift/src/Ice/LocalExceptions.swift b/swift/src/Ice/LocalExceptions.swift index a004502e3e0..813bedab85f 100644 --- a/swift/src/Ice/LocalExceptions.swift +++ b/swift/src/Ice/LocalExceptions.swift @@ -430,5 +430,5 @@ public final class TwowayOnlyException: LocalException { } } -/// This exception is raised when trying to get or set an unknown property. -public final class UnknownPropertyException: LocalException {} +/// This exception is raised when there is an error while getting or setting a property. +public final class PropertyException: LocalException {} diff --git a/swift/src/IceImpl/Properties.mm b/swift/src/IceImpl/Properties.mm index 167274cd205..5421083f7e9 100644 --- a/swift/src/IceImpl/Properties.mm +++ b/swift/src/IceImpl/Properties.mm @@ -17,7 +17,7 @@ - (NSString*)getProperty:(NSString*)key - (NSString*)getIceProperty:(NSString*)key; { - // We don't catch exceptions on purpose; in particular, we want Ice::UnknownPropertyException to terminate + // We don't catch exceptions on purpose; in particular, we want Ice::PropertyException to terminate // the application. return toNSString(self.properties->getIceProperty(fromNSString(key))); } diff --git a/swift/test/Ice/properties/Client.swift b/swift/test/Ice/properties/Client.swift index 1e39d92b96b..b048c1ea2dd 100644 --- a/swift/test/Ice/properties/Client.swift +++ b/swift/test/Ice/properties/Client.swift @@ -138,8 +138,8 @@ public class Client: TestHelperI { // Cannot test in Swift since this generates a fatal error. _ = properties.getIceProperty("Ice.UnknownProperty") try test(false) - } catch let error as UnknownPropertyException { - try test(error.ice_id() == "::Ice::UnknownPropertyException") + } catch let error as PropertyException { + try test(error.ice_id() == "::Ice::PropertyException") try test(error.message == "unknown Ice property: Ice.UnknownProperty") } From 22b772c8af859bb9352868173152c38f47ee5b4d Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 28 Oct 2024 14:10:57 -0400 Subject: [PATCH 05/10] Windows fix --- cpp/include/DataStorm/Node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/include/DataStorm/Node.h b/cpp/include/DataStorm/Node.h index aa71c1f8761..34931ee4885 100644 --- a/cpp/include/DataStorm/Node.h +++ b/cpp/include/DataStorm/Node.h @@ -114,7 +114,7 @@ namespace DataStorm wchar_t* argv[], std::optional configFile = std::nullopt, std::function call)> customExecutor = nullptr) - : Node(argc, const_cast(argv), configFile, customExecutor) + : Node(argc, const_cast(argv), configFile, customExecutor) { } #endif From 8a575a32db4772dc2a5c894110d34819ca925c25 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 28 Oct 2024 15:07:28 -0400 Subject: [PATCH 06/10] Fix test --- cpp/test/Common/TestHelper.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cpp/test/Common/TestHelper.cpp b/cpp/test/Common/TestHelper.cpp index 931461890f4..a93cca93e4d 100644 --- a/cpp/test/Common/TestHelper.cpp +++ b/cpp/test/Common/TestHelper.cpp @@ -26,6 +26,14 @@ namespace } #endif + + void parseTestOptions(int& argc, char* argv[], const Ice::PropertiesPtr& properties) + { + Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); + args = properties->parseCommandLineOptions("Test", args); + args = properties->parseCommandLineOptions("TestAdapter", args); + Ice::stringSeqToArgs(args, argc, argv); + } } #if TARGET_OS_IPHONE != 0 @@ -276,10 +284,7 @@ Ice::PropertiesPtr Test::TestHelper::createTestProperties(int& argc, char* argv[]) { Ice::PropertiesPtr properties = Ice::createProperties(argc, argv); - Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); - args = properties->parseCommandLineOptions("Test", args); - args = properties->parseCommandLineOptions("TestAdapter", args); - Ice::stringSeqToArgs(args, argc, argv); + parseTestOptions(argc, argv, properties); return properties; } @@ -287,7 +292,15 @@ Ice::CommunicatorPtr Test::TestHelper::initialize(int& argc, char* argv[], const Ice::PropertiesPtr& properties) { Ice::InitializationData initData; - initData.properties = properties ? properties : createTestProperties(argc, argv); + if (properties) + { + parseTestOptions(argc, argv, properties); + initData.properties = properties; + } + else + { + initData.properties = createTestProperties(argc, argv); + } return initialize(argc, argv, initData); } From a50f850c205826e113433bc4d922d2c867bbe840 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 28 Oct 2024 15:11:44 -0400 Subject: [PATCH 07/10] Properties clone fix --- cpp/src/Ice/Properties.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/src/Ice/Properties.cpp b/cpp/src/Ice/Properties.cpp index 4459aea37ac..e24daf519ca 100644 --- a/cpp/src/Ice/Properties.cpp +++ b/cpp/src/Ice/Properties.cpp @@ -81,6 +81,7 @@ Ice::Properties::Properties(const Properties& p) { lock_guard lock(p._mutex); _properties = p._properties; + _servicePrefix = p._servicePrefix; } Ice::Properties::Properties(StringSeq& args, const PropertiesPtr& defaults) From 5a33ad2d8969db3183e8b6a4cf40deb88fb50793 Mon Sep 17 00:00:00 2001 From: Joe George Date: Tue, 29 Oct 2024 12:10:27 -0400 Subject: [PATCH 08/10] Fixes --- config/PropertyNames.xml | 30 +++++++-------- config/makeprops.py | 20 +++++----- cpp/include/DataStorm/Node.h | 17 +++------ cpp/include/Ice/Properties.h | 11 +++--- cpp/src/DataStorm/Node.cpp | 6 +-- cpp/src/Glacier2/Glacier2Router.cpp | 2 +- cpp/src/Ice/Properties.cpp | 11 +++--- cpp/src/Ice/PropertyNames.cpp | 40 ++++++++++---------- cpp/src/Ice/PropertyNames.h | 2 +- cpp/src/IceBox/Admin.cpp | 2 +- cpp/src/IceBox/IceBoxService.cpp | 4 +- cpp/src/IceBox/ServiceManagerI.cpp | 9 ++--- cpp/src/IceBridge/IceBridge.cpp | 2 +- cpp/src/IceGrid/Client.cpp | 2 +- cpp/src/IceGrid/IceGridNode.cpp | 2 +- cpp/src/IceGrid/IceGridRegistry.cpp | 2 +- cpp/src/IceStorm/Admin.cpp | 2 +- cpp/test/DataStorm/api/Writer.cpp | 6 +-- cpp/test/Ice/properties/Client.cpp | 3 +- cpp/test/IceStorm/federation/Publisher.cpp | 2 +- cpp/test/IceStorm/federation/Subscriber.cpp | 3 +- cpp/test/IceStorm/federation2/Publisher.cpp | 2 +- cpp/test/IceStorm/federation2/Subscriber.cpp | 3 +- cpp/test/IceStorm/persistent/Client.cpp | 2 +- cpp/test/IceStorm/rep1/Publisher.cpp | 2 +- cpp/test/IceStorm/rep1/Sub.cpp | 3 +- cpp/test/IceStorm/rep1/Subscriber.cpp | 3 +- cpp/test/IceStorm/repstress/Publisher.cpp | 2 +- cpp/test/IceStorm/repstress/Subscriber.cpp | 3 +- cpp/test/IceStorm/single/Publisher.cpp | 3 +- cpp/test/IceStorm/single/Subscriber.cpp | 3 +- cpp/test/IceStorm/stress/Publisher.cpp | 3 +- cpp/test/IceStorm/stress/Subscriber.cpp | 2 +- 33 files changed, 106 insertions(+), 103 deletions(-) diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 503ab19101f..474859a5ce7 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -65,7 +65,7 @@ --> -
+
@@ -160,7 +160,7 @@
-
+
@@ -169,7 +169,7 @@
-
+
@@ -184,7 +184,7 @@
-
+
@@ -198,7 +198,7 @@
-
+
@@ -207,17 +207,17 @@
-
+
-
+
-
+
@@ -236,7 +236,7 @@
-
+
@@ -301,7 +301,7 @@
-
+
@@ -333,7 +333,7 @@
-
+
@@ -360,18 +360,18 @@
-
+
-
+
-
+
@@ -398,7 +398,7 @@
-
+
diff --git a/config/makeprops.py b/config/makeprops.py index ad04d445d42..a310214ddd4 100755 --- a/config/makeprops.py +++ b/config/makeprops.py @@ -35,12 +35,10 @@ class Language(StrEnum): class PropertyArray: - def __init__( - self, name: str, prefixOnly: bool, isClass: bool, isServicePrefix: bool - ): + def __init__(self, name: str, prefixOnly: bool, isClass: bool, isOptIn: bool): self.name = name self.prefixOnly = prefixOnly - self.isServicePrefix = isServicePrefix + self.isOptIn = isOptIn self.isClass = isClass self.properties = [] @@ -192,19 +190,19 @@ def startElement(self, name, attrs): name=name, prefixOnly=prefixOnly, isClass=True, - isServicePrefix=False, + isOptIn=False, ) case "section": - isServicePrefix = attrs.get("service-prefix", "false").lower() == "true" + isOptIn = attrs.get("opt-in", "false").lower() == "true" name = attrs.get("name") - self.validateKnownAttributes(["name", "service-prefix"], attrs) + self.validateKnownAttributes(["name", "opt-in"], attrs) self.parentNodeName = name self.propertyArrayDict[self.parentNodeName] = PropertyArray( name=name, prefixOnly=False, isClass=False, - isServicePrefix=isServicePrefix, + isOptIn=isOptIn, ) case "property": @@ -277,7 +275,7 @@ def openFiles(self): const bool prefixOnly; const Property* properties; const int length; - const bool isServicePrefix; + const bool isOptIn; }}; class PropertyNames @@ -319,7 +317,7 @@ def fix(self, propertyName): def writePropertyArray(self, propertyArray): name = propertyArray.name prefixOnly = "true" if propertyArray.prefixOnly else "false" - isServicePrefix = "true" if propertyArray.isServicePrefix else "false" + isOptIn = "true" if propertyArray.isOptIn else "false" self.hFile.write(f" static const PropertyArray {name}Props;\n") self.cppFile.write(f"""\ @@ -334,7 +332,7 @@ def writePropertyArray(self, propertyArray): .prefixOnly={prefixOnly}, .properties={name}PropsData, .length={len(propertyArray.properties)}, - .isServicePrefix={isServicePrefix} + .isOptIn={isOptIn} }}; """) diff --git a/cpp/include/DataStorm/Node.h b/cpp/include/DataStorm/Node.h index 34931ee4885..e5edaa899ae 100644 --- a/cpp/include/DataStorm/Node.h +++ b/cpp/include/DataStorm/Node.h @@ -38,8 +38,7 @@ namespace DataStorm /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice - * communicator. + * A node is the main DataStorm object. It is required to construct topics. * * @param argc The number of arguments in argv. * @param argv The configuration arguments. @@ -57,8 +56,7 @@ namespace DataStorm /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice - * communicator. + * A node is the main DataStorm object. It is required to construct topics. * * @param argc The number of arguments in argv. * @param argv The configuration arguments. @@ -80,8 +78,7 @@ namespace DataStorm /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice - * communicator. + * A node is the main DataStorm object. It is required to construct topics. * * @param argc The number of arguments in argv. * @param argv The configuration arguments. @@ -99,8 +96,7 @@ namespace DataStorm /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice - * communicator. + * A node is the main DataStorm object. It is required to construct topics. * * @param argc The number of arguments in argv. * @param argv The configuration arguments. @@ -122,8 +118,7 @@ namespace DataStorm /** * Construct a DataStorm node. * - * A node is the main DataStorm object. It is required to construct topics. The node uses the given Ice - * communicator. + * A node is the main DataStorm object. It is required to construct topics. * * @param configFile The path to an optional Ice configuration file. * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is @@ -140,7 +135,7 @@ namespace DataStorm * communicator. * * @param communicator The Ice communicator used by the topic factory for its configuration and communications. - * This communicator must be initialized with a property set to use the "DataStorm" service prefix. + * This communicator must be initialized with a property set to use the "DataStorm" opt-in prefix. * @param customExecutor An optional executor used to execute user callbacks, if no callback executor is * provided the Node will use the default callback executor that executes callback in a dedicated thread. */ diff --git a/cpp/include/Ice/Properties.h b/cpp/include/Ice/Properties.h index b56b509e034..f1047728329 100644 --- a/cpp/include/Ice/Properties.h +++ b/cpp/include/Ice/Properties.h @@ -35,10 +35,10 @@ namespace Ice Properties() = default; /** - * Constructs an empty property set with the given property service prefix. - * @param servicePrefix The property set to copy. + * Constructs an empty property set with a list of opt-in prefixes. + * @param optInPrefixes The list of opt-in prefixes to allow in the property set. */ - explicit Properties(std::string_view servicePrefix) : _servicePrefix(servicePrefix) {} + explicit Properties(std::vector optInPrefixes) : _optInPrefixes(optInPrefixes) {} /** * Copy constructor. @@ -233,8 +233,9 @@ namespace Ice bool used; }; std::map> _properties; - // The service prefix is used to allow Ice services to set service specific prefixed properties. - std::optional _servicePrefix; + // List of "opt-in" property prefixes to allow in the property set. Setting a property for a property prefix + // that is opt-in (eg. IceGrid, IceStorm, Glacier2, etc.) but not in this list is considered an error. + std::vector _optInPrefixes; mutable std::mutex _mutex; }; } diff --git a/cpp/src/DataStorm/Node.cpp b/cpp/src/DataStorm/Node.cpp index 73f6454c01f..94181b4bd01 100644 --- a/cpp/src/DataStorm/Node.cpp +++ b/cpp/src/DataStorm/Node.cpp @@ -16,7 +16,7 @@ namespace Ice::CommunicatorPtr argsToCommunicator(int& argc, const char* argv[], optional configFile) { - Ice::PropertiesPtr properties = make_shared("DataStorm"); + Ice::PropertiesPtr properties = make_shared(vector{"DataStorm"}); if (configFile) { @@ -32,7 +32,7 @@ namespace #ifdef _WIN32 Ice::CommunicatorPtr argsToCommunicator(int& argc, const wchar_t* argv[], optional configFile) { - Ice::PropertiesPtr properties = make_shared("DataStorm"); + Ice::PropertiesPtr properties = make_shared(vector{"DataStorm"}); if (configFile) { @@ -48,7 +48,7 @@ namespace Ice::CommunicatorPtr configToCommunicator(optional configFile) { - Ice::PropertiesPtr properties = make_shared("DataStorm"); + Ice::PropertiesPtr properties = make_shared(vector{"DataStorm"}); if (configFile) { diff --git a/cpp/src/Glacier2/Glacier2Router.cpp b/cpp/src/Glacier2/Glacier2Router.cpp index b9f81207f16..b324fe65225 100644 --- a/cpp/src/Glacier2/Glacier2Router.cpp +++ b/cpp/src/Glacier2/Glacier2Router.cpp @@ -488,6 +488,6 @@ main(int argc, char* argv[]) RouterService svc; // Initialize the service with a Properties object with the correct property prefix enabled. Ice::InitializationData initData; - initData.properties = make_shared("Glacier2"); + initData.properties = make_shared(vector{"Glacier2"}); return svc.main(argc, argv, initData); } diff --git a/cpp/src/Ice/Properties.cpp b/cpp/src/Ice/Properties.cpp index e24daf519ca..484c6a77ea6 100644 --- a/cpp/src/Ice/Properties.cpp +++ b/cpp/src/Ice/Properties.cpp @@ -81,7 +81,7 @@ Ice::Properties::Properties(const Properties& p) { lock_guard lock(p._mutex); _properties = p._properties; - _servicePrefix = p._servicePrefix; + _optInPrefixes = p._optInPrefixes; } Ice::Properties::Properties(StringSeq& args, const PropertiesPtr& defaults) @@ -90,7 +90,7 @@ Ice::Properties::Properties(StringSeq& args, const PropertiesPtr& defaults) { lock_guard lock(defaults->_mutex); _properties = defaults->_properties; - _servicePrefix = defaults->_servicePrefix; + _optInPrefixes = defaults->_optInPrefixes; } StringSeq::iterator q = args.begin(); @@ -321,11 +321,12 @@ Ice::Properties::setProperty(string_view key, string_view value) // Check if the property is in an Ice property prefix. If so, check that it's a valid property. if (auto propertyArray = findIcePropertyArray(key)) { - if (propertyArray->isServicePrefix && - (_servicePrefix != propertyArray->name && propertyArray->name != string{"IceStorm"})) + if (propertyArray->isOptIn && + find(_optInPrefixes.begin(), _optInPrefixes.end(), propertyArray->name) == _optInPrefixes.end()) { ostringstream os; - os << "unable to set '" << key << "': property prefix '" << propertyArray->name << "' is reserved."; + os << "unable to set '" << key << "': property prefix '" << propertyArray->name + << "' is opt-in and must be explicitly enabled."; throw PropertyException{__FILE__, __LINE__, os.str()}; } string propertyPrefix{propertyArray->name}; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 5b3571bfee5..ca567bcb79f 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -28,7 +28,7 @@ const PropertyArray PropertyNames::ProxyProps .prefixOnly=false, .properties=ProxyPropsData, .length=9, - .isServicePrefix=false + .isOptIn=false }; const Property ConnectionPropsData[] = @@ -47,7 +47,7 @@ const PropertyArray PropertyNames::ConnectionProps .prefixOnly=true, .properties=ConnectionPropsData, .length=6, - .isServicePrefix=false + .isOptIn=false }; const Property ThreadPoolPropsData[] = @@ -65,7 +65,7 @@ const PropertyArray PropertyNames::ThreadPoolProps .prefixOnly=true, .properties=ThreadPoolPropsData, .length=5, - .isServicePrefix=false + .isOptIn=false }; const Property ObjectAdapterPropsData[] = @@ -90,7 +90,7 @@ const PropertyArray PropertyNames::ObjectAdapterProps .prefixOnly=true, .properties=ObjectAdapterPropsData, .length=12, - .isServicePrefix=false + .isOptIn=false }; const Property LMDBPropsData[] = @@ -105,7 +105,7 @@ const PropertyArray PropertyNames::LMDBProps .prefixOnly=true, .properties=LMDBPropsData, .length=2, - .isServicePrefix=false + .isOptIn=false }; const Property IcePropsData[] = @@ -201,7 +201,7 @@ const PropertyArray PropertyNames::IceProps .prefixOnly=false, .properties=IcePropsData, .length=83, - .isServicePrefix=false + .isOptIn=false }; const Property IceMXPropsData[] = @@ -220,7 +220,7 @@ const PropertyArray PropertyNames::IceMXProps .prefixOnly=false, .properties=IceMXPropsData, .length=6, - .isServicePrefix=false + .isOptIn=false }; const Property IceDiscoveryPropsData[] = @@ -244,7 +244,7 @@ const PropertyArray PropertyNames::IceDiscoveryProps .prefixOnly=false, .properties=IceDiscoveryPropsData, .length=11, - .isServicePrefix=false + .isOptIn=false }; const Property IceLocatorDiscoveryPropsData[] = @@ -268,7 +268,7 @@ const PropertyArray PropertyNames::IceLocatorDiscoveryProps .prefixOnly=false, .properties=IceLocatorDiscoveryPropsData, .length=11, - .isServicePrefix=false + .isOptIn=false }; const Property IceBoxPropsData[] = @@ -287,7 +287,7 @@ const PropertyArray PropertyNames::IceBoxProps .prefixOnly=false, .properties=IceBoxPropsData, .length=6, - .isServicePrefix=true + .isOptIn=true }; const Property IceBoxAdminPropsData[] = @@ -301,7 +301,7 @@ const PropertyArray PropertyNames::IceBoxAdminProps .prefixOnly=false, .properties=IceBoxAdminPropsData, .length=1, - .isServicePrefix=true + .isOptIn=true }; const Property IceBridgePropsData[] = @@ -317,7 +317,7 @@ const PropertyArray PropertyNames::IceBridgeProps .prefixOnly=false, .properties=IceBridgePropsData, .length=3, - .isServicePrefix=true + .isOptIn=true }; const Property IceGridAdminPropsData[] = @@ -343,7 +343,7 @@ const PropertyArray PropertyNames::IceGridAdminProps .prefixOnly=false, .properties=IceGridAdminPropsData, .length=13, - .isServicePrefix=true + .isOptIn=true }; const Property IceGridPropsData[] = @@ -418,7 +418,7 @@ const PropertyArray PropertyNames::IceGridProps .prefixOnly=false, .properties=IceGridPropsData, .length=62, - .isServicePrefix=true + .isOptIn=true }; const Property IceSSLPropsData[] = @@ -452,7 +452,7 @@ const PropertyArray PropertyNames::IceSSLProps .prefixOnly=false, .properties=IceSSLPropsData, .length=21, - .isServicePrefix=false + .isOptIn=false }; const Property IceStormPropsData[] = @@ -489,7 +489,7 @@ const PropertyArray PropertyNames::IceStormProps .prefixOnly=false, .properties=IceStormPropsData, .length=24, - .isServicePrefix=true + .isOptIn=true }; const Property IceStormAdminPropsData[] = @@ -505,7 +505,7 @@ const PropertyArray PropertyNames::IceStormAdminProps .prefixOnly=false, .properties=IceStormAdminPropsData, .length=3, - .isServicePrefix=true + .isOptIn=true }; const Property IceBTPropsData[] = @@ -520,7 +520,7 @@ const PropertyArray PropertyNames::IceBTProps .prefixOnly=false, .properties=IceBTPropsData, .length=2, - .isServicePrefix=false + .isOptIn=false }; const Property Glacier2PropsData[] = @@ -557,7 +557,7 @@ const PropertyArray PropertyNames::Glacier2Props .prefixOnly=false, .properties=Glacier2PropsData, .length=24, - .isServicePrefix=true + .isOptIn=true }; const Property DataStormPropsData[] = @@ -583,7 +583,7 @@ const PropertyArray PropertyNames::DataStormProps .prefixOnly=false, .properties=DataStormPropsData, .length=13, - .isServicePrefix=true + .isOptIn=true }; const std::array PropertyNames::validProps = diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index f6d885dfa3c..b679b18b841 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -31,7 +31,7 @@ namespace IceInternal const bool prefixOnly; const Property* properties; const int length; - const bool isServicePrefix; + const bool isOptIn; }; class PropertyNames diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp index e43d0ac400f..7ebe7ab418d 100644 --- a/cpp/src/IceBox/Admin.cpp +++ b/cpp/src/IceBox/Admin.cpp @@ -35,7 +35,7 @@ main(int argc, char* argv[]) // Initialize with a Properties object with the correct property prefix enabled. Ice::InitializationData initData; - initData.properties = make_shared("IceBoxAdmin"); + initData.properties = make_shared(vector{"IceBoxAdmin"}); Ice::CommunicatorHolder ich{argc, argv, initData}; diff --git a/cpp/src/IceBox/IceBoxService.cpp b/cpp/src/IceBox/IceBoxService.cpp index b5e89fe6604..4179bdf04c0 100644 --- a/cpp/src/IceBox/IceBoxService.cpp +++ b/cpp/src/IceBox/IceBoxService.cpp @@ -131,7 +131,9 @@ main(int argc, char* argv[]) InitializationData initData; // Initialize the service with a Properties object with the correct property prefix enabled. - initData.properties = make_shared("IceBox"); + // Since IceStorm is an IceBox service, we need to enable the IceBox property prefix as we allow configuring + // IceStorm properties through IceBox properties. + initData.properties = make_shared(vector{"IceBox", "IceStorm"}); initData.properties->setProperty("Ice.Admin.DelayCreation", "1"); return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 1da46816d13..4884bb8ef9c 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -851,8 +851,9 @@ IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, exc Ice::PropertiesPtr IceBox::ServiceManagerI::createServiceProperties(const string& service) { - // We don't want to clone the properties object as we don't want to copy the service prefix. - PropertiesPtr properties = make_shared(); + // We don't want to clone the properties object as we don't want to copy the opt-in prefix list. + // NOTE: We always enable the "IceStorm" prefix as there's currently no way to distinguish it. + PropertiesPtr properties = make_shared(vector{"IceStorm"}); PropertiesPtr communicatorProperties = _communicator->getProperties(); if (communicatorProperties->getPropertyAsInt("IceBox.InheritProperties") > 0) { @@ -865,10 +866,6 @@ IceBox::ServiceManagerI::createServiceProperties(const string& service) } } } - else - { - properties = createProperties(); - } string programName = communicatorProperties->getProperty("Ice.ProgramName"); if (programName.empty()) diff --git a/cpp/src/IceBridge/IceBridge.cpp b/cpp/src/IceBridge/IceBridge.cpp index 91e15d9dc1e..56c7bd62bb9 100644 --- a/cpp/src/IceBridge/IceBridge.cpp +++ b/cpp/src/IceBridge/IceBridge.cpp @@ -627,6 +627,6 @@ main(int argc, char* argv[]) BridgeService svc; // Initialize the service with a Properties object with the correct property prefix enabled. Ice::InitializationData initData; - initData.properties = make_shared("IceBridge"); + initData.properties = make_shared(vector{"IceBridge"}); return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index 52660962600..ef79e2d8438 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -80,7 +80,7 @@ main(int argc, char* argv[]) { Ice::CtrlCHandler ctrlCHandler; // Initialize IceGrid properties with a Properties object with the correct property prefix enabled. - auto defaultProps = make_shared("IceGridAdmin"); + auto defaultProps = make_shared(vector{"IceGridAdmin"}); defaultProps->setProperty("IceGridAdmin.Server.Endpoints", "tcp -h localhost"); // Turn-off inactivity timeout for outgoing connections. diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index b6a22908a3c..0bc32c270eb 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -815,6 +815,6 @@ main(int argc, char* argv[]) NodeService svc; // Initialize the service with a Properties object with the correct property prefix enabled. Ice::InitializationData initData; - initData.properties = make_shared("IceGrid"); + initData.properties = make_shared(vector{"IceGrid"}); return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index 0db4b81c432..57a12fd61e5 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -237,6 +237,6 @@ main(int argc, char* argv[]) RegistryService svc; // Initialize the service with a Properties object with the correct property prefix enabled. Ice::InitializationData initData; - initData.properties = make_shared("IceGrid"); + initData.properties = make_shared(vector{"IceGrid", "IceStorm"}); return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp index 6f2367e3390..75a03c95d77 100644 --- a/cpp/src/IceStorm/Admin.cpp +++ b/cpp/src/IceStorm/Admin.cpp @@ -36,7 +36,7 @@ main(int argc, char* argv[]) Ice::CtrlCHandler ctrlCHandler; Ice::InitializationData id; - id.properties = make_shared("IceStormAdmin"); + id.properties = make_shared(vector{"IceStormAdmin"}); id.properties->setProperty("Ice.Warn.Endpoints", "0"); Ice::CommunicatorHolder ich(argc, argv, id); diff --git a/cpp/test/DataStorm/api/Writer.cpp b/cpp/test/DataStorm/api/Writer.cpp index 7eef2b163c2..2721dc50f50 100644 --- a/cpp/test/DataStorm/api/Writer.cpp +++ b/cpp/test/DataStorm/api/Writer.cpp @@ -27,15 +27,15 @@ main(int argc, char* argv[]) } { - // Communicators shared with DataStorm must have a property set that can use the "DataStorm" service prefix. + // Communicators shared with DataStorm must have a property set that can use the "DataStorm" opt-in prefix. Ice::InitializationData initData; - initData.properties = make_shared("DataStorm"); + initData.properties = make_shared(vector{"DataStorm"}); Node n2(Ice::initialize(initData)); n2.getCommunicator()->destroy(); } Ice::InitializationData initData; - initData.properties = make_shared("DataStorm"); + initData.properties = make_shared(vector{"DataStorm"}); auto c = Ice::initialize(initData); { Node n22(c); diff --git a/cpp/test/Ice/properties/Client.cpp b/cpp/test/Ice/properties/Client.cpp index 6b99012055f..508637cf167 100644 --- a/cpp/test/Ice/properties/Client.cpp +++ b/cpp/test/Ice/properties/Client.cpp @@ -195,7 +195,8 @@ Client::run(int, char**) } cout << "ok" << endl; - cout << "testing that setting a property in a reserved service prefix throws an exception..." << flush; + cout << "testing that setting a property in an opt-in prefix that is not configured throws an exception..." + << flush; try { properties->setProperty("IceGrid.InstanceName", "TestGrid"); diff --git a/cpp/test/IceStorm/federation/Publisher.cpp b/cpp/test/IceStorm/federation/Publisher.cpp index f5b1a94b94c..44b86e74af6 100644 --- a/cpp/test/IceStorm/federation/Publisher.cpp +++ b/cpp/test/IceStorm/federation/Publisher.cpp @@ -21,7 +21,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); Ice::CommunicatorPtr communicator = ich.communicator(); string managerProxy = communicator->getProperties()->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index 37dc28d08e4..6d484df1e8c 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -49,7 +49,8 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); bool batch = false; int idx = 1; diff --git a/cpp/test/IceStorm/federation2/Publisher.cpp b/cpp/test/IceStorm/federation2/Publisher.cpp index f602404d52a..999929dabc3 100644 --- a/cpp/test/IceStorm/federation2/Publisher.cpp +++ b/cpp/test/IceStorm/federation2/Publisher.cpp @@ -23,7 +23,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto communicator = ich.communicator(); IceInternal::Options opts; opts.addOpt("", "count", IceInternal::Options::NeedArg); diff --git a/cpp/test/IceStorm/federation2/Subscriber.cpp b/cpp/test/IceStorm/federation2/Subscriber.cpp index 791960b9c94..035ec86bb83 100644 --- a/cpp/test/IceStorm/federation2/Subscriber.cpp +++ b/cpp/test/IceStorm/federation2/Subscriber.cpp @@ -63,7 +63,8 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); bool batch = false; int idx = 1; diff --git a/cpp/test/IceStorm/persistent/Client.cpp b/cpp/test/IceStorm/persistent/Client.cpp index 8bb2e1deba3..c0612724ff7 100644 --- a/cpp/test/IceStorm/persistent/Client.cpp +++ b/cpp/test/IceStorm/persistent/Client.cpp @@ -22,7 +22,7 @@ class Client final : public Test::TestHelper void Client::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto communicator = ich.communicator(); auto properties = communicator->getProperties(); auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); diff --git a/cpp/test/IceStorm/rep1/Publisher.cpp b/cpp/test/IceStorm/rep1/Publisher.cpp index e1047197328..d08d727f40d 100644 --- a/cpp/test/IceStorm/rep1/Publisher.cpp +++ b/cpp/test/IceStorm/rep1/Publisher.cpp @@ -24,7 +24,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto communicator = ich.communicator(); IceInternal::Options opts; opts.addOpt("", "cycle"); diff --git a/cpp/test/IceStorm/rep1/Sub.cpp b/cpp/test/IceStorm/rep1/Sub.cpp index b30a3e6f6de..3a5b53f7cb8 100644 --- a/cpp/test/IceStorm/rep1/Sub.cpp +++ b/cpp/test/IceStorm/rep1/Sub.cpp @@ -30,7 +30,8 @@ class Sub final : public Test::TestHelper void Sub::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); IceInternal::Options opts; opts.addOpt("", "id", IceInternal::Options::NeedArg); opts.addOpt("", "unsub"); diff --git a/cpp/test/IceStorm/rep1/Subscriber.cpp b/cpp/test/IceStorm/rep1/Subscriber.cpp index 8b026602f8a..94b5ca7473e 100644 --- a/cpp/test/IceStorm/rep1/Subscriber.cpp +++ b/cpp/test/IceStorm/rep1/Subscriber.cpp @@ -73,7 +73,8 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); IceInternal::Options opts; opts.addOpt("", "ordered"); opts.addOpt("", "twoway"); diff --git a/cpp/test/IceStorm/repstress/Publisher.cpp b/cpp/test/IceStorm/repstress/Publisher.cpp index a08d21c97c0..8a7b694c19a 100644 --- a/cpp/test/IceStorm/repstress/Publisher.cpp +++ b/cpp/test/IceStorm/repstress/Publisher.cpp @@ -76,7 +76,7 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto communicator = ich.communicator(); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); diff --git a/cpp/test/IceStorm/repstress/Subscriber.cpp b/cpp/test/IceStorm/repstress/Subscriber.cpp index d89d3acbaaf..0f620981962 100644 --- a/cpp/test/IceStorm/repstress/Subscriber.cpp +++ b/cpp/test/IceStorm/repstress/Subscriber.cpp @@ -41,7 +41,8 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/single/Publisher.cpp b/cpp/test/IceStorm/single/Publisher.cpp index 0cc879d2a72..4006a04e79e 100644 --- a/cpp/test/IceStorm/single/Publisher.cpp +++ b/cpp/test/IceStorm/single/Publisher.cpp @@ -23,7 +23,8 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index 9c8e14c4a84..1c503be1bdf 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -106,7 +106,8 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if (managerProxy.empty()) diff --git a/cpp/test/IceStorm/stress/Publisher.cpp b/cpp/test/IceStorm/stress/Publisher.cpp index 44d331d59cb..db653c19bb5 100644 --- a/cpp/test/IceStorm/stress/Publisher.cpp +++ b/cpp/test/IceStorm/stress/Publisher.cpp @@ -25,7 +25,8 @@ class Publisher final : public Test::TestHelper void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder communicator = + initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); IceInternal::Options opts; opts.addOpt("", "events", IceInternal::Options::NeedArg); opts.addOpt("", "oneway"); diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index 57199e05c1d..93000dd4b8b 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -239,7 +239,7 @@ class Subscriber final : public Test::TestHelper void Subscriber::run(int argc, char** argv) { - Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared("IceStormAdmin")); + Ice::CommunicatorHolder ich = initialize(argc, argv, make_shared(vector{"IceStormAdmin"})); auto communicator = ich.communicator(); IceInternal::Options opts; opts.addOpt("", "events", IceInternal::Options::NeedArg); From eac6ffb6bc82d6686893fa1853bf758f6c8b0fe3 Mon Sep 17 00:00:00 2001 From: Joe George Date: Tue, 29 Oct 2024 12:14:11 -0400 Subject: [PATCH 09/10] Review fix --- cpp/include/DataStorm/Node.h | 2 +- cpp/src/DataStorm/Node.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/include/DataStorm/Node.h b/cpp/include/DataStorm/Node.h index e5edaa899ae..7ab53d6254f 100644 --- a/cpp/include/DataStorm/Node.h +++ b/cpp/include/DataStorm/Node.h @@ -197,7 +197,7 @@ namespace DataStorm private: Node( - const Ice::CommunicatorPtr&, + Ice::CommunicatorPtr, std::function call)> customExecutor, bool ownsCommunicator); diff --git a/cpp/src/DataStorm/Node.cpp b/cpp/src/DataStorm/Node.cpp index 94181b4bd01..d3319d0291c 100644 --- a/cpp/src/DataStorm/Node.cpp +++ b/cpp/src/DataStorm/Node.cpp @@ -99,7 +99,7 @@ Node::Node(Ice::CommunicatorPtr communicator, function cal } Node::Node( - const Ice::CommunicatorPtr& communicator, + Ice::CommunicatorPtr communicator, std::function call)> customExecutor, bool ownsCommunicator) : _ownsCommunicator(ownsCommunicator) From bbe419374e0604d9f42cea0e6ac0bf72f9106ca1 Mon Sep 17 00:00:00 2001 From: Joe George Date: Tue, 29 Oct 2024 14:18:43 -0400 Subject: [PATCH 10/10] review fix --- cpp/include/Ice/Properties.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/include/Ice/Properties.h b/cpp/include/Ice/Properties.h index f1047728329..6ed4a657e8d 100644 --- a/cpp/include/Ice/Properties.h +++ b/cpp/include/Ice/Properties.h @@ -38,7 +38,7 @@ namespace Ice * Constructs an empty property set with a list of opt-in prefixes. * @param optInPrefixes The list of opt-in prefixes to allow in the property set. */ - explicit Properties(std::vector optInPrefixes) : _optInPrefixes(optInPrefixes) {} + explicit Properties(std::vector optInPrefixes) : _optInPrefixes(std::move(optInPrefixes)) {} /** * Copy constructor.