Skip to content

[refactor] Connection code unnecessary uses TreeMap as parameter, field, or variable type #25782

@lhotari

Description

@lhotari

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions