]> source.dussan.org Git - sonarqube.git/commitdiff
fix java:S2259 possible NPE
authorPierre <pierre.guillot@sonarsource.com>
Fri, 13 Mar 2020 09:59:25 +0000 (10:59 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 13 Mar 2020 20:04:14 +0000 (20:04 +0000)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/util/cache/ProtobufIssueDiskCache.java

index 3dc527a31ad12afa0304058aa93ec389891be9f4..602981259fc24317a789ea27835b96e5248575d6 100644 (file)
@@ -27,6 +27,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
+import java.io.Serializable;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Map;
@@ -247,11 +248,13 @@ public class ProtobufIssueDiskCache implements DiskCache<DefaultIssue> {
 
     for (Map.Entry<String, FieldDiffs.Diff> e : fieldDiffs.diffs().entrySet()) {
       IssueCache.Diff.Builder diffBuilder = IssueCache.Diff.newBuilder();
-      if (e.getValue().oldValue() != null) {
-        diffBuilder.setOldValue(e.getValue().oldValue().toString());
+      Serializable oldValue = e.getValue().oldValue();
+      if (oldValue != null) {
+        diffBuilder.setOldValue(oldValue.toString());
       }
-      if (e.getValue().newValue() != null) {
-        diffBuilder.setNewValue(e.getValue().newValue().toString());
+      Serializable newValue = e.getValue().newValue();
+      if (newValue != null) {
+        diffBuilder.setNewValue(newValue.toString());
 
       }
       builder.putDiffs(e.getKey(), diffBuilder.build());