Skip to content

Commit

Permalink
Use getIceProperty as appropriate (#3153)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Nov 15, 2024
1 parent abf2c53 commit 54548fe
Show file tree
Hide file tree
Showing 31 changed files with 74 additions and 94 deletions.
2 changes: 1 addition & 1 deletion cpp/src/Ice/DefaultsAndOverrides.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro

const_cast<bool&>(defaultPreferSecure) = properties->getIcePropertyAsInt("Ice.Default.PreferSecure") > 0;

value = properties->getPropertyWithDefault("Ice.Default.EncodingVersion", encodingVersionToString(currentEncoding));
value = properties->getIceProperty("Ice.Default.EncodingVersion");
defaultEncoding = stringToEncodingVersion(value);
checkSupportedEncoding(defaultEncoding);

Expand Down
6 changes: 5 additions & 1 deletion cpp/src/Ice/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ Ice::Service::main(int argc, const char* const argv[], const InitializationData&
_logger = getProcessLogger();
if (dynamic_pointer_cast<LoggerI>(_logger))
{
string eventLogSource = initData.properties->getPropertyWithDefault("Ice.EventLog.Source", name);
string eventLogSource = initData.properties->getIceProperty("Ice.EventLog.Source");
if (eventLogSource.empty())
{
eventLogSource = name;
}
_logger = make_shared<SMEventLoggerIWrapper>(
make_shared<SMEventLoggerI>(eventLogSource, stringConverter),
"");
Expand Down
10 changes: 3 additions & 7 deletions cpp/src/IceDiscovery/PluginI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,10 @@ PluginI::initialize()

bool ipv4 = properties->getIcePropertyAsInt("Ice.IPv4") > 0;
bool preferIPv6 = properties->getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
string address;
if (ipv4 && !preferIPv6)
string address = properties->getIceProperty("IceDiscovery.Address");
if (address.empty())
{
address = properties->getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1");
}
else
{
address = properties->getPropertyWithDefault("IceDiscovery.Address", "ff15::1");
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties->getIcePropertyAsInt("IceDiscovery.Port");
string intf = properties->getIceProperty("IceDiscovery.Interface");
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/IceGrid/IceGridNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ NodeService::startImpl(int argc, char* argv[], int& status)
//
// Warn the user that setting Ice.ThreadPool.Server isn't useful.
//
if (!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
if (!nowarn && !properties->getProperty("Ice.ThreadPool.Server.Size").empty())
{
Warning out(communicator()->getLogger());
out << "setting `Ice.ThreadPool.Server.Size' is not useful, ";
out << "setting 'Ice.ThreadPool.Server.Size' is not useful, ";
out << "you should set individual adapter thread pools instead.";
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/IceGrid/IceGridRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ RegistryService::start(int argc, char* argv[], int& status)
//
// Warn the user that setting Ice.ThreadPool.Server isn't useful.
//
if (!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
if (!nowarn && !properties->getProperty("Ice.ThreadPool.Server.Size").empty())
{
Warning out(communicator()->getLogger());
out << "setting `Ice.ThreadPool.Server.Size' is not useful, ";
out << "setting 'Ice.ThreadPool.Server.Size' is not useful, ";
out << "you should set individual adapter thread pools instead.";
}

Expand Down
10 changes: 3 additions & 7 deletions cpp/src/IceGrid/RegistryI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,10 @@ RegistryI::startImpl()
{
bool ipv4 = properties->getIcePropertyAsInt("Ice.IPv4") > 0;
bool preferIPv6 = properties->getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
string address;
if (ipv4 && !preferIPv6)
string address = properties->getIceProperty("IceGrid.Registry.Discovery.Address");
if (address.empty())
{
address = properties->getPropertyWithDefault("IceGrid.Registry.Discovery.Address", "239.255.0.1");
}
else
{
address = properties->getPropertyWithDefault("IceGrid.Registry.Discovery.Address", "ff15::1");
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties->getIcePropertyAsInt("IceGrid.Registry.Discovery.Port");
string interface = properties->getIceProperty("IceGrid.Registry.Discovery.Interface");
Expand Down
10 changes: 3 additions & 7 deletions cpp/src/IceLocatorDiscovery/PluginI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,10 @@ PluginI::initialize()

bool ipv4 = properties->getIcePropertyAsInt("Ice.IPv4") > 0;
bool preferIPv6 = properties->getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
string address;
if (ipv4 && !preferIPv6)
string address = properties->getIceProperty("IceLocatorDiscovery.Address");
if (address.empty())
{
address = properties->getPropertyWithDefault("IceLocatorDiscovery.Address", "239.255.0.1");
}
else
{
address = properties->getPropertyWithDefault("IceLocatorDiscovery.Address", "ff15::1");
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties->getIcePropertyAsInt("IceLocatorDiscovery.Port");
string intf = properties->getIceProperty("IceLocatorDiscovery.Interface");
Expand Down
12 changes: 10 additions & 2 deletions cpp/src/iceserviceinstall/ServiceInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
addLog(eventLog);
}

string eventLogSource = _serviceProperties->getPropertyWithDefault("Ice.EventLog.Source", _serviceName);
string eventLogSource = _serviceProperties->getIceProperty("Ice.EventLog.Source");
if (eventLogSource.empty())
{
eventLogSource = _serviceName;
}

addSource(eventLogSource, eventLog, getIceDLLPath(imagePath));

Expand Down Expand Up @@ -366,7 +370,11 @@ IceServiceInstaller::uninstall()
CloseServiceHandle(scm);
CloseServiceHandle(service);

string eventLogSource = _serviceProperties->getPropertyWithDefault("Ice.EventLog.Source", _serviceName);
string eventLogSource = _serviceProperties->getIceProperty("Ice.EventLog.Source");
if (eventLogSource.empty())
{
eventLogSource = _serviceName;
}
string eventLog = removeSource(eventLogSource);

if (eventLog != "Application")
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/Common/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Test::TestHelper::getTestEndpoint(const Ice::PropertiesPtr& properties, int num,
std::string protocol = prot;
if (protocol.empty())
{
protocol = properties->getPropertyWithDefault("Ice.Default.Protocol", "default");
protocol = properties->getIceProperty("Ice.Default.Protocol");
}

int basePort = properties->getPropertyAsIntWithDefault("Test.BasePort", 12010);
Expand Down
6 changes: 3 additions & 3 deletions cpp/test/Ice/networkProxy/AllTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ allTests(Test::TestHelper* helper)
{
Ice::CommunicatorPtr communicator = helper->communicator();

int proxyPort = communicator->getProperties()->getPropertyAsInt("Ice.HTTPProxyPort");
if (proxyPort == 0)
int proxyPort = communicator->getProperties()->getIcePropertyAsInt("Ice.HTTPProxyPort");
if (proxyPort == 1080) // default, i.e. most likely not set
{
proxyPort = communicator->getProperties()->getPropertyAsInt("Ice.SOCKSProxyPort");
proxyPort = communicator->getProperties()->getIcePropertyAsInt("Ice.SOCKSProxyPort");
}

TestIntfPrx testPrx(communicator, "test:" + helper->getTestEndpoint());
Expand Down
4 changes: 2 additions & 2 deletions csharp/src/Ice/Internal/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ internal void initialize(Ice.Communicator communicator, Ice.InitializationData i
_referenceFactory = new ReferenceFactory(this, communicator);

bool isIPv6Supported = Network.isIPv6Supported();
bool ipv4 = _initData.properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0;
bool ipv6 = _initData.properties.getPropertyAsIntWithDefault("Ice.IPv6", isIPv6Supported ? 1 : 0) > 0;
bool ipv4 = _initData.properties.getIcePropertyAsInt("Ice.IPv4") > 0;
bool ipv6 = isIPv6Supported && _initData.properties.getIcePropertyAsInt("Ice.IPv6") > 0;
if (!ipv4 && !ipv6)
{
throw new Ice.InitializationException("Both IPV4 and IPv6 support cannot be disabled.");
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Ice/Internal/ThreadPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void executeFromThisThread(System.Action call, Ice.Connection connection)
}
catch (System.Exception ex)
{
if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
if (_instance.initializationData().properties.getIcePropertyAsInt("Ice.Warn.Dispatch") > 0)
{
_instance.initializationData().logger.warning("dispatch exception:\n" + ex);
}
Expand Down
10 changes: 3 additions & 7 deletions csharp/src/IceDiscovery/PluginI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ public void initialize()

bool ipv4 = properties.getIcePropertyAsInt("Ice.IPv4") > 0;
bool preferIPv6 = properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
string address;
if (ipv4 && !preferIPv6)
string address = properties.getIceProperty("IceDiscovery.Address");
if (address.Length == 0)
{
address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1");
}
else
{
address = properties.getPropertyWithDefault("IceDiscovery.Address", "ff15::1");
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties.getIcePropertyAsInt("IceDiscovery.Port");
string intf = properties.getIceProperty("IceDiscovery.Interface");
Expand Down
10 changes: 3 additions & 7 deletions csharp/src/IceLocatorDiscovery/PluginI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,14 +659,10 @@ public void

bool ipv4 = properties.getIcePropertyAsInt("Ice.IPv4") > 0;
bool preferIPv6 = properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
string address;
if (ipv4 && !preferIPv6)
string address = properties.getIceProperty("IceLocatorDiscovery.Address");
if (address.Length == 0)
{
address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "239.255.0.1");
}
else
{
address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "ff15::1");
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties.getIcePropertyAsInt("IceLocatorDiscovery.Port");
string intf = properties.getIceProperty("IceLocatorDiscovery.Interface");
Expand Down
2 changes: 1 addition & 1 deletion csharp/test/Ice/background/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override async Task runAsync(string[] args)
// Setup the test transport plug-in.
//
properties.setProperty("Ice.Default.Protocol",
"test-" + properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"));
"test-" + properties.getIceProperty("Ice.Default.Protocol"));

using (var communicator = initialize(properties))
{
Expand Down
2 changes: 1 addition & 1 deletion csharp/test/Ice/background/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override void run(string[] args)
// Setup the test transport plug-in.
//
properties.setProperty("Ice.Default.Protocol",
"test-" + properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"));
"test-" + properties.getIceProperty("Ice.Default.Protocol"));

using (var communicator = initialize(properties))
{
Expand Down
6 changes: 3 additions & 3 deletions csharp/test/Ice/networkProxy/AllTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public static void allTests(Test.TestHelper helper)
Ice.ObjectPrx obj = communicator.stringToProxy(sref);
test(obj != null);

int proxyPort = communicator.getProperties().getPropertyAsInt("Ice.HTTPProxyPort");
if (proxyPort == 0)
int proxyPort = communicator.getProperties().getIcePropertyAsInt("Ice.HTTPProxyPort");
if (proxyPort == 1080) // default, i.e. most likely not set
{
proxyPort = communicator.getProperties().getPropertyAsInt("Ice.SOCKSProxyPort");
proxyPort = communicator.getProperties().getIcePropertyAsInt("Ice.SOCKSProxyPort");
}

Test.TestIntfPrx testPrx = Test.TestIntfPrxHelper.checkedCast(obj);
Expand Down
4 changes: 2 additions & 2 deletions csharp/test/TestCommon/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public string getTestEndpoint(int num = 0, string protocol = "")
public static string getTestEndpoint(Ice.Properties properties, int num = 0, string protocol = "")
{
StringBuilder sb = new StringBuilder();
sb.Append(protocol.Length == 0 ? properties.getPropertyWithDefault("Ice.Default.Protocol", "default") :
sb.Append(protocol.Length == 0 ? properties.getIceProperty("Ice.Default.Protocol") :
protocol);
sb.Append(" -p ");
sb.Append(properties.getPropertyAsIntWithDefault("Test.BasePort", 12010) + num);
Expand All @@ -88,7 +88,7 @@ public String getTestProtocol()

public static String getTestProtocol(Ice.Properties properties)
{
return properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
return properties.getIceProperty("Ice.Default.Protocol");
}

public int getTestPort(int num)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ final class DefaultsAndOverrides {

defaultPreferSecure = properties.getIcePropertyAsInt("Ice.Default.PreferSecure") > 0;

value =
properties.getPropertyWithDefault(
"Ice.Default.EncodingVersion",
Util.encodingVersionToString(Protocol.currentEncoding));
value = properties.getIceProperty("Ice.Default.EncodingVersion");
defaultEncoding = Util.stringToEncodingVersion(value);
Protocol.checkSupportedEncoding(defaultEncoding);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ public void initialize() {

boolean ipv4 = properties.getIcePropertyAsInt("Ice.IPv4") > 0;
boolean preferIPv6 = properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
String address;
if (ipv4 && !preferIPv6) {
address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1");
} else {
address = properties.getPropertyWithDefault("IceDiscovery.Address", "ff15::1");
String address = properties.getIceProperty("IceDiscovery.Address");
if (address.isEmpty()) {
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties.getIcePropertyAsInt("IceDiscovery.Port");
String intf = properties.getIceProperty("IceDiscovery.Interface");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,9 @@ public void initialize() {

boolean ipv4 = properties.getIcePropertyAsInt("Ice.IPv4") > 0;
boolean preferIPv6 = properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
String address;
if (ipv4 && !preferIPv6) {
address =
properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "239.255.0.1");
} else {
address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "ff15::1");
String address = properties.getIceProperty("IceLocatorDiscovery.Address");
if (address.isEmpty()) {
address = ipv4 && !preferIPv6 ? "239.255.0.1" : "ff15::1";
}
int port = properties.getIcePropertyAsInt("IceLocatorDiscovery.Port");
String intf = properties.getIceProperty("IceLocatorDiscovery.Interface");
Expand Down
7 changes: 4 additions & 3 deletions java/test/src/main/java/test/Ice/networkProxy/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public static void allTests(test.TestHelper helper) {
com.zeroc.Ice.ObjectPrx obj = communicator.stringToProxy(sref);
test(obj != null);

int proxyPort = communicator.getProperties().getPropertyAsInt("Ice.HTTPProxyPort");
if (proxyPort == 0) {
proxyPort = communicator.getProperties().getPropertyAsInt("Ice.SOCKSProxyPort");
int proxyPort = communicator.getProperties().getIcePropertyAsInt("Ice.HTTPProxyPort");
// default, i.e. most likely not set
if (proxyPort == 1080) {
proxyPort = communicator.getProperties().getIcePropertyAsInt("Ice.SOCKSProxyPort");
}

TestIntfPrx test = TestIntfPrx.checkedCast(obj);
Expand Down
4 changes: 2 additions & 2 deletions java/test/src/main/java/test/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static String getTestEndpoint(
com.zeroc.Ice.Properties properties, int num, String prot) {
String protocol = prot;
if (protocol.isEmpty()) {
protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "default");
protocol = properties.getIceProperty("Ice.Default.Protocol");
}

int basePort = properties.getPropertyAsIntWithDefault("Test.BasePort", 12010);
Expand Down Expand Up @@ -86,7 +86,7 @@ public String getTestProtocol() {
}

public static String getTestProtocol(com.zeroc.Ice.Properties properties) {
return properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
return properties.getIceProperty("Ice.Default.Protocol");
}

public int getTestPort(int num) {
Expand Down
2 changes: 1 addition & 1 deletion js/src/Ice/ReferenceFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export class ReferenceFactory {
throw new ParseException(`invalid endpoint '${unknownEndpoints[0]}' in '${s}'`);
} else if (
unknownEndpoints.length !== 0 &&
this._instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0
this._instance.initializationData().properties.getIcePropertyAsInt("Ice.Warn.Endpoints") > 0
) {
const msg = [];
msg.push("Proxy contains unknown endpoints:");
Expand Down
4 changes: 2 additions & 2 deletions js/test/Common/TestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TestHelper {
}

if (protocol == "") {
protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "default");
protocol = properties.getIceProperty("Ice.Default.Protocol");
}

const port = properties.getPropertyAsIntWithDefault("Test.BasePort", 12010) + num;
Expand All @@ -57,7 +57,7 @@ export class TestHelper {
if (properties === undefined) {
properties = this._communicator.getProperties();
}
return properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
return properties.getIceProperty("Ice.Default.Protocol");
}

getTestPort(...args) {
Expand Down
2 changes: 1 addition & 1 deletion js/test/Ice/proxy/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Client extends TestHelper {
const communicator = this.communicator();
const out = this.getWriter();

const defaultProtocol = communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp");
const defaultProtocol = communicator.getProperties().getIceProperty("Ice.Default.Protocol");

const base = new Ice.ObjectPrx(communicator, `test:${this.getTestEndpoint()}`);

Expand Down
4 changes: 2 additions & 2 deletions php/test/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getTestEndpoint()

if($protocol == "")
{
$protocol = $properties->getPropertyWithDefault("Ice.Default.Protocol", "default");
$protocol = $properties->getIceProperty("Ice.Default.Protocol");
}

$port = $properties->getPropertyAsIntWithDefault("Test.BasePort", 12010) + $num;
Expand All @@ -103,7 +103,7 @@ public function getTestProtocol($properties=NULL)
$properties = $this->_communicator->getProperties();
}

return $properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
return $properties->getIceProperty("Ice.Default.Protocol");
}

public function getTestPort()
Expand Down
Loading

0 comments on commit 54548fe

Please sign in to comment.