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
This commit is contained in:
Steve Loughran 2023-03-08 15:53:17 +00:00
parent fc4a4e9a9a
commit def228225d
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
2 changed files with 3 additions and 12 deletions

View File

@ -451,7 +451,7 @@
</Match> </Match>
<Match> <Match>
<Class name="org.apache.hadoop.ipc.impl.ShadedProtobufHelper" /> <Class name="org.apache.hadoop.ipc.internal.ShadedProtobufHelper" />
<Bug pattern="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION" /> <Bug pattern="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION" />
</Match> </Match>
</FindBugsFilter> </FindBugsFilter>

View File

@ -83,12 +83,7 @@ public final class ShadedProtobufHelper {
ByteString value = FIXED_BYTESTRING_CACHE.get(key); ByteString value = FIXED_BYTESTRING_CACHE.get(key);
if (value == null) { if (value == null) {
value = ByteString.copyFromUtf8(key.toString()); value = ByteString.copyFromUtf8(key.toString());
final Text key1 = new Text(key.copyBytes()); FIXED_BYTESTRING_CACHE.put(new Text(key.copyBytes()), value);
synchronized (FIXED_BYTESTRING_CACHE) {
if (FIXED_BYTESTRING_CACHE.get(key1) == null) {
FIXED_BYTESTRING_CACHE.put(key1, value);
}
}
} }
return value; return value;
} }
@ -102,11 +97,7 @@ public final class ShadedProtobufHelper {
ByteString value = FIXED_BYTESTRING_CACHE.get(key); ByteString value = FIXED_BYTESTRING_CACHE.get(key);
if (value == null) { if (value == null) {
value = ByteString.copyFromUtf8(key); value = ByteString.copyFromUtf8(key);
synchronized (FIXED_BYTESTRING_CACHE) { FIXED_BYTESTRING_CACHE.put(key, value);
if (FIXED_BYTESTRING_CACHE.get(key) == null) {
FIXED_BYTESTRING_CACHE.put(key, value);
}
}
} }
return value; return value;
} }