From def228225d2d1015ddd5143228e37a6e8c4fb2b3 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Wed, 8 Mar 2023 15:53:17 +0000 Subject: [PATCH] HADOOP-18487. Disable spotbugs warnings of currency issues It's not a real issue, just risk of duplicate writing to the cache, where that is considered acceptable. Change-Id: I11ef64d2bd0a303e678e114fb38317194d1b50cd --- .../dev-support/findbugsExcludeFile.xml | 2 +- .../hadoop/ipc/internal/ShadedProtobufHelper.java | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml b/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml index 7fef704f4a4..fdc90ed3c96 100644 --- a/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml +++ b/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml @@ -451,7 +451,7 @@ - + diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/internal/ShadedProtobufHelper.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/internal/ShadedProtobufHelper.java index 9a5b144920f..b43875b00c1 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/internal/ShadedProtobufHelper.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/internal/ShadedProtobufHelper.java @@ -83,12 +83,7 @@ public final class ShadedProtobufHelper { ByteString value = FIXED_BYTESTRING_CACHE.get(key); if (value == null) { value = ByteString.copyFromUtf8(key.toString()); - final Text key1 = new Text(key.copyBytes()); - synchronized (FIXED_BYTESTRING_CACHE) { - if (FIXED_BYTESTRING_CACHE.get(key1) == null) { - FIXED_BYTESTRING_CACHE.put(key1, value); - } - } + FIXED_BYTESTRING_CACHE.put(new Text(key.copyBytes()), value); } return value; } @@ -102,11 +97,7 @@ public final class ShadedProtobufHelper { ByteString value = FIXED_BYTESTRING_CACHE.get(key); if (value == null) { value = ByteString.copyFromUtf8(key); - synchronized (FIXED_BYTESTRING_CACHE) { - if (FIXED_BYTESTRING_CACHE.get(key) == null) { - FIXED_BYTESTRING_CACHE.put(key, value); - } - } + FIXED_BYTESTRING_CACHE.put(key, value); } return value; }