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

SocketFactory overridden if `ssl=true` is used in the URI

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

      Here is a simple test that demonstrates the issue

      public class Foo {
      
          public static void main(String[] args) {
              String uri = "mongodb://localhost/test?ssl=true";
              SocketFactory socketFactory = mock(SocketFactory.class);
              MongoClientOptions.Builder options = MongoClientOptions
                      .builder()
                      .sslEnabled(true)
                      .socketFactory(socketFactory);
              MongoClient mongoClient = new MongoClient(new MongoClientURI(uri, options));
              MongoClientOptions mongoClientOptions = mongoClient.getMongoClientOptions();
              assertThat(mongoClientOptions.isSslEnabled()).isTrue();
              assertThat(mongoClientOptions.getSocketFactory()).isEqualTo(socketFactory);
          }
      }
      

      A call to sslEnabled will reset the factory.

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

              Created:
              Updated:
              Resolved: