The existing code (before this PR) unnecessarily uses TreeMap as parameter, field, or variable types. A general recommendation is to use the minimal Map interface type, usually one of java.util.Map, java.util.SequencedMap, or java.util.SortedMap. In the case of connectors, the use the TreeMap is justified as the implementation to get stable iteration order by key. This is available when java.util.Map is the parameter, field, or variable type.
I'd suggest addressing the refactoring to get rid of unnecessary use of TreeMap in parameter, field, and variable types for connector related classes after this current PR has been merged. For example,
In ConnectorsManager
@Getter
private volatile Map<String, Connector> connectors;
The implementation instance would remain as TreeMap, so this change would only be about the types for fields, variables and parameters.
public record ReloadConnectorsResult(Map<String, Connector> connectors, List<Connector> connectorsToClose) {
}
This change could also be made part of this PR since it already closes touches the code where TreeMap is used and also adds a new TreeMap parameter/field in ReloadConnectorsResult.
Originally posted by @lhotari in #25773 (review)
The existing code (before this PR) unnecessarily uses TreeMap as parameter, field, or variable types. A general recommendation is to use the minimal Map interface type, usually one of
java.util.Map,java.util.SequencedMap, orjava.util.SortedMap. In the case of connectors, the use the TreeMap is justified as the implementation to get stable iteration order by key. This is available whenjava.util.Mapis the parameter, field, or variable type.I'd suggest addressing the refactoring to get rid of unnecessary use of TreeMap in parameter, field, and variable types for connector related classes after this current PR has been merged. For example,
In ConnectorsManager
The implementation instance would remain as
TreeMap, so this change would only be about the types for fields, variables and parameters.This change could also be made part of this PR since it already closes touches the code where
TreeMapis used and also adds a newTreeMapparameter/field in ReloadConnectorsResult.Originally posted by @lhotari in #25773 (review)