[JAVA-3632] Ignore redundant null check error from Spotbugs Created: 21/Feb/20  Updated: 28/Oct/23  Resolved: 21/Feb/20

Status: Closed
Project: Java Driver
Component/s: Build
Affects Version/s: 4.0.0, 4.1.0
Fix Version/s: 4.0.0

Type: Improvement Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

See https://github.com/spotbugs/spotbugs/issues/756 for details.

Essentially, Java 11 has changed the bytecode generation for try-with-resources, and it triggers this Spotbugs error wherever it's used:

Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE

Since this is a relatively harmless mistake in handwritten code, and try-with-resources is quite nice syntactically, let's disable the check.



 Comments   
Comment by Githook User [ 21/Feb/20 ]

Author:

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

Message: Disable RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE Spotbugs check

Spotbugs plugin complains about an extraneous null check for any use
of try-with-resources compiled with Java 11. Until the issue is
addressed by Spotbugs, disabling the check.

JAVA-3632
Branch: 4.0.x
https://github.com/mongodb/mongo-java-driver/commit/0ef0b3551916612c4c88e73eb90ff1aab1fac442

Comment by Githook User [ 21/Feb/20 ]

Author:

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

Message: Disable RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE Spotbugs check

Spotbugs plugin complains about an extraneous null check for any use
of try-with-resources compiled with Java 11. Until the issue is
addressed by Spotbugs, disabling the check.

JAVA-3632
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e780bb22c52bc1e8e0cbdee881b95eb8da96c972

Comment by Jeffrey Yemin [ 21/Feb/20 ]

https://github.com/jyemin/mongo-java-driver/pull/362

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