smiklosovic commented on code in PR #2046:
URL: https://github.com/apache/cassandra/pull/2046#discussion_r1053356340
##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1747,10 +1767,10 @@ public static InetAddressAndPort getReplaceAddress()
{
try
{
- if (System.getProperty(Config.PROPERTY_PREFIX + "replace_address",
null) != null)
- return
InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX +
"replace_address", null));
- else if (System.getProperty(Config.PROPERTY_PREFIX +
"replace_address_first_boot", null) != null)
- return
InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX +
"replace_address_first_boot", null));
+ if (REPLACE_ADDRESS.getString(null) != null)
Review Comment:
is not `getString(null)` redundant here? The same behavior is achieved with
`getString()` as `null` is default anyway. Another option is to do
`REPLACE_ADDRESS("cassandra.replace_address", null)` but why would one do it,
right?
I would also rework this like:
````
String replaceAddress = REPLACE_ADDRESS.getString();
if (replaceAddress != null)
return InetAddressAndPort.getByName(replaceAddress);
String replaceAddressFirstBoot = REPLACE_ADDRESS_FIRST_BOOT.getString();
if (replaceAddressFirstBoot != null)
return InetAddressAndPort.getByName(replaceAddressFirstBoot);
return null;
````
The current (and previous) code is resolving properties in the worst case
three times. That is not necessary. With this way of doing that we resolve it
once or at most twice.
Resolving it just once also means that it can not happen that we read it for
the first time but somebody changes the value of that property before we read
it for the second time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]