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

ClientEncryptions.create throws NPE if the key vault client settings are not specified

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.10.0
    • Affects Version/s: None
    • Component/s: Client Side Encryption
    • None
    • Minor Change
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Users are not required to specify the key vault client settings via ClientEncryptionSettings. Moreover, the documentation of ClientEncryptionSettings.getKeyVaultMongoClientSettings says "May be null to indicate that the same MongoClient should be used to access the key vault collection as is used for the rest of the application". In practice, we have this:

      java.lang.IllegalArgumentException: settings can not be null
      
      	at com.mongodb.assertions.Assertions.notNull(Assertions.java:48)
      	at com.mongodb.client.internal.MongoClientImpl.createCluster(MongoClientImpl.java:227)
      	at com.mongodb.client.internal.MongoClientImpl.<init>(MongoClientImpl.java:72)
      	at com.mongodb.client.MongoClients.create(MongoClients.java:108)
      	at com.mongodb.client.MongoClients.create(MongoClients.java:50)
      	at com.mongodb.client.internal.ClientEncryptionImpl.<init>(ClientEncryptionImpl.java:69)
      	at com.mongodb.client.vault.ClientEncryptions.create(ClientEncryptions.java:37)
      

      When this ticket is done, we should do the changes necessary to get rid of the following SpotBugs exclusions in mongo-java-driver/config/spotbugs/exclude.xml

      <Match>
          <Class name="com.mongodb.client.internal.ClientEncryptionImpl"/>
          <Method name="createEncryptedCollection"/>
          <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
      </Match>
      <Match>
          <Class name="com.mongodb.reactivestreams.client.internal.vault.ClientEncryptionImpl"/>
          <Method name="~.*createEncryptedCollection.*"/>
          <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
      </Match>
      

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: