[JAVA-4542] Using BasicDBObject.parse(String) on OpenJDK 11.0.8 yields NPE Created: 22/Mar/22  Updated: 27/Oct/23  Resolved: 22/Mar/22

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mikael Östberg Assignee: Jeffrey Yemin
Resolution: Works as Designed Votes: 0
Labels: external-user
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

When using BasicDBObject.parse(String) on OpenJDK 11.0.8 it yields an NPE directly on the signature without any further stacktrace. 

We first noticed this on a couple internal Jenkins agents that suddenly were displaying a intermittent failure of a category of tests, troubleshooting narrowed it down to a single worker that was running a separate jdk. Using other agents solved the problem. 

How to Reproduce

Use Java OpenJDK 11.0.8 and run a main or a test-method with the mongodb-java-driver 3.8.2 on the classpath. Use  

@Test
public void simpleTest() {
   String json = "{ \"_id\" : \"0\" }";
   BasicDBObject.parse(json);
}

Results in: 

This is output when ran from maven. 
16:01:14 [ERROR] Errors: 16:01:14 [ERROR] MongoDBTest.simpleTest:19 » NullPointer

Resolved by:

We resolved this problem by updating to the latest and greatest, but it worked already with the next patch-bump to OpenJDK 11.0.9.



 Comments   
Comment by Jeffrey Yemin [ 22/Mar/22 ]

It's definitely interesting, but there is not enough to go on to pursue it further. 

I'm going to close the issue, but definitely anyone who sees anything similar and has more info, please add a comment, and we can consider next steps.

Comment by Mikael Östberg [ 22/Mar/22 ]

If i had more stacktrace to share i literally would. We're equally confused as to why the stacktrace is missing from both the junit-reports and stdout.
The NullPointer is thrown upon attempting to use the static BasicDBObject.parse method with a single-argument. That much we know. But i have no idea because of what. The string provided is very static and created on the line before so it is not the string. 

 

I agree with your deduction that it is a JDK bug and not a driver-bug, but it surfaces from using your library so i thought you might want to know about it. 

Comment by Jeffrey Yemin [ 22/Mar/22 ]

Please share the full stack trace.  At first glance it would seem like a JDK bug not a driver bug.

Generated at Thu Feb 08 09:02:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.