From 80200572878c86e5e4014504d786c07c69b986d8 Mon Sep 17 00:00:00 2001 From: Valentin Kovalenko Date: Thu, 16 May 2024 10:21:58 -0600 Subject: [PATCH 1/4] Augment `config/spotbugs/exclude.xml` with finding status and rank JAVA-5431 --- bson/src/main/org/bson/types/ObjectId.java | 3 +- config/spotbugs/exclude.xml | 167 +++++++-------------- 2 files changed, 58 insertions(+), 112 deletions(-) diff --git a/bson/src/main/org/bson/types/ObjectId.java b/bson/src/main/org/bson/types/ObjectId.java index 57c1d8c373..7c1b1d2954 100644 --- a/bson/src/main/org/bson/types/ObjectId.java +++ b/bson/src/main/org/bson/types/ObjectId.java @@ -57,7 +57,7 @@ public final class ObjectId implements Comparable, Serializable { private static final int RANDOM_VALUE1; private static final short RANDOM_VALUE2; - private static final AtomicInteger NEXT_COUNTER = new AtomicInteger(new SecureRandom().nextInt()); + private static final AtomicInteger NEXT_COUNTER; private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', @@ -409,6 +409,7 @@ private Object readResolve() { SecureRandom secureRandom = new SecureRandom(); RANDOM_VALUE1 = secureRandom.nextInt(0x01000000); RANDOM_VALUE2 = (short) secureRandom.nextInt(0x00008000); + NEXT_COUNTER = new AtomicInteger(secureRandom.nextInt()); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index d35f0a81c8..8ded96c281 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -14,214 +14,158 @@ ~ limitations under the License. --> + - - - - - + + + + + - + + - - - + + - + + - + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + - - - - - - - - - - - + + + - + + - + + + + + + + + + + - + + + - + + @@ -229,36 +173,35 @@ + + - + + - - - - - + - + @@ -268,11 +211,13 @@ see: https://github.com/Kotlin/kotlinx.coroutines/issues/3099 --> + + From d06e1ff418ab2a03c138b9cb1edaeac622798f0b Mon Sep 17 00:00:00 2001 From: Valentin Kovalenko Date: Thu, 16 May 2024 11:22:15 -0600 Subject: [PATCH 2/4] Remove an unnecessary exclusion JAVA-5431 --- config/spotbugs/exclude.xml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index 8ded96c281..1033cf48a9 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -14,7 +14,7 @@ ~ limitations under the License. --> - @@ -141,13 +141,6 @@ - - - - - - - @@ -155,7 +148,6 @@ - From d949b608f5cb12b4532d36d22132bd89197c1e77 Mon Sep 17 00:00:00 2001 From: Valentin Kovalenko Date: Thu, 16 May 2024 16:19:16 -0600 Subject: [PATCH 3/4] Address review concerns JAVA-5431 --- bson/src/main/org/bson/types/ObjectId.java | 3 +-- config/spotbugs/exclude.xml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bson/src/main/org/bson/types/ObjectId.java b/bson/src/main/org/bson/types/ObjectId.java index 7c1b1d2954..57c1d8c373 100644 --- a/bson/src/main/org/bson/types/ObjectId.java +++ b/bson/src/main/org/bson/types/ObjectId.java @@ -57,7 +57,7 @@ public final class ObjectId implements Comparable, Serializable { private static final int RANDOM_VALUE1; private static final short RANDOM_VALUE2; - private static final AtomicInteger NEXT_COUNTER; + private static final AtomicInteger NEXT_COUNTER = new AtomicInteger(new SecureRandom().nextInt()); private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', @@ -409,7 +409,6 @@ private Object readResolve() { SecureRandom secureRandom = new SecureRandom(); RANDOM_VALUE1 = secureRandom.nextInt(0x01000000); RANDOM_VALUE2 = (short) secureRandom.nextInt(0x00008000); - NEXT_COUNTER = new AtomicInteger(secureRandom.nextInt()); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index 1033cf48a9..40ed1b7ac7 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -121,7 +121,7 @@ - + From f6dd54baa80f133c84d1440d34a37f8779010393 Mon Sep 17 00:00:00 2001 From: Valentin Kovalenko Date: Tue, 21 May 2024 10:37:46 -0600 Subject: [PATCH 4/4] `RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE` is a "False Positive" We discussed it, experimented with it during a catchup meeting, and established that this finding is a false positive. JAVA-5431 --- config/spotbugs/exclude.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index 40ed1b7ac7..fb0e4e9ec0 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -142,7 +142,7 @@ - +