Skip to content

Conversation

@ebyhr
Copy link

@ebyhr ebyhr commented Dec 23, 2025

The existing Properties constructor at L266 creates an empty property list. We should explicitly call putAll method.

@ebyhr ebyhr requested a review from a team as a code owner December 23, 2025 08:43
Properties properties = new Properties(info);
properties.put("user", this.getUsername());
properties.put("password", this.getPassword());
properties.putAll(info);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes little sense to have the properties constructed with info if we already add all its properties.

Properties properties = new Properties(info);
properties.put("user", this.getUsername());
properties.put("password", this.getPassword());
properties.putAll(info);
Copy link

@findinpath findinpath Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix makes sense

public class TestProperties
{
    public static void main(String[] args)
    {
        Properties properties = new Properties();
        properties.setProperty("key1", "value1");
        properties.setProperty("key2", "value2");
        properties.forEach((k, v) -> System.out.println(k + ": " + v));

        System.out.println("--- After Copy ---");

        Properties newProperties  = new Properties(properties);
        newProperties.forEach((k, v) -> System.out.println(k + ": " + v));


        System.out.println("--- Defaults ---");
        System.out.println(newProperties.getProperty("key1"));
        System.out.println(newProperties.getProperty("unknown"));

    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants