Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2271

ConnectionString.getCredentialList should return immutable List

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.0-rc1, 3.4.0
    • Affects Version/s: 3.0.0
    • Component/s: API, Configuration
    • None

      It's a potential source of bugs for applications who write code like:

        new ConnectionString(...).getCredentialList().add(...);
      

      thinking that a credential is added to the list. But ConnectionString is actually immutable, and getCredentialList returns a new ArrayList each time it's called, making that call a no-op.

      The getCredentialList implementation should be updated to return an immutable list so that the above code results in a runtime exception, and the documentation should be updated to reflect that.

      The ConnectionString class should also be annotated with @Immutable.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: