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

NullPointerException in ClientMetadataHelper.getDriverVersion

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.3, 3.5.0
    • Affects Version/s: 3.4.0
    • Component/s: Monitoring
    • Labels:
      None
    • Environment:
      java version "1.8.0_111"
      Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
      Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode, sharing)

      Java Driver throws NPE in:

      at com.mongodb.connection.ClientMetadataHelper.getDriverVersion(ClientMetadataHelper.java:113)
      at com.mongodb.connection.ClientMetadataHelper.getDriverInformation(ClientMetadataHelper.java:201)
      at com.mongodb.connection.ClientMetadataHelper.addDriverInformation(ClientMetadataHelper.java:182)
      at com.mongodb.connection.ClientMetadataHelper.<clinit>(ClientMetadataHelper.java:64)
      

      We are running the driver in environment where

      InternalStreamConnectionInitializer.class.getProtectionDomain().getCodeSource().getLocation()
      

      returns null (some strange classloader)
      and it throws in NPE here:

      String path = codeSource.getLocation().getPath();
      

      It would be better to check it for nullness and for example set driverVersion = "unknown" (as it is being done in case of other errors).

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            piotr@dydycz.com Piotr Dydycz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: