Mmuzaf commented on code in PR #2046:
URL: https://github.com/apache/cassandra/pull/2046#discussion_r1168527195
##########
test/distributed/org/apache/cassandra/distributed/shared/WithProperties.java:
##########
@@ -80,35 +75,28 @@ public void set(CassandraRelevantProperties prop, long
value)
set(prop, Long.toString(value));
}
- public void with(String key, String value)
- {
- String previous = System.setProperty(key, value);
- properties.add(new Property(key, previous));
- }
-
-
@Override
public void close()
{
Collections.reverse(properties);
properties.forEach(s -> {
- if (s.value == null)
- System.getProperties().remove(s.key);
+ if (s.prevValue == null)
+ s.prop.clearValue();
else
- System.setProperty(s.key, s.value);
+ s.prop.setString(s.prevValue);
});
properties.clear();
}
private static final class Property
{
- private final String key;
- private final String value;
+ private final CassandraRelevantProperties prop;
Review Comment:
The main point for this change - we should enforce a contract for setting
and removing system properties listed in `CassandraRelevantProperties`. I have
thought about your concern and found the following solution:
- we use `set` and `clear` methods for the properties related to
`CassandraRelevantProperties`;
- we use `System.clearProperty` and `System.setProperty` for those
properties that exist only at runtime e.g. `cassandra.setings.` prefixed
properties;
I have reworked the `WithProperties' to fit both of the above cases and the
changes are not too complicated for now.
WDYT?
--
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]