[JAVA-2449] NullPointerException in ClientMetadataHelper.getDriverVersion Created: 14/Feb/17  Updated: 02/Aug/17  Resolved: 09/Mar/17

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: 3.4.0
Fix Version/s: 3.4.3, 3.5.0

Type: Bug Priority: Major - P3
Reporter: Piotr Dydycz Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
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)


Issue Links:
Duplicate
duplicates JAVA-2494 Connection failure from Android Closed

 Description   

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).



 Comments   
Comment by Githook User [ 09/Mar/17 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2449: Add null check for codeSource location when constructing client metadata document
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f72027767992081174ce9588d48898068e650d5c

Comment by Jeffrey Yemin [ 14/Feb/17 ]

That's sufficient.

Thanks,
Jeff

Comment by Piotr Dydycz [ 14/Feb/17 ]

It is running inside Software AG webMethods Integration Server (mongo driver is deployed inside Integration Server package).
My brief investigation shows that custom classloader is used for classes loaded within packages.

What else you want to know?

Comment by Jeffrey Yemin [ 14/Feb/17 ]

Can you describe the environment in which the application is running? I'd like to understand the root cause a little better to see how common this might be.

Generated at Thu Feb 08 08:57:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.