]> source.dussan.org Git - sonarqube.git/commitdiff
should not assign null when using Optional
authorZipeng WU <zipeng.wu@sonarsource.com>
Tue, 8 Dec 2020 15:31:40 +0000 (16:31 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 9 Dec 2020 20:07:21 +0000 (20:07 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java

index 64bf8ebacdfd9c206092bc1c5571f24ab6f8fd22..225e6fcdd1ca1bde830c1a7efe03a7503f84e7c3 100644 (file)
@@ -35,7 +35,7 @@ public class LinesJsonWriter {
   }
 
   public void writeSource(Iterable<DbFileSources.Line> lines, JsonWriter json, Supplier<Optional<Long>> periodDateSupplier) {
-    Optional<Long> periodDate = null;
+    Long periodDate = null;
 
     json.name("sources").beginArray();
     for (DbFileSources.Line line : lines) {
@@ -64,9 +64,9 @@ public class LinesJsonWriter {
         json.prop("isNew", line.getIsNewLine());
       } else {
         if (periodDate == null) {
-          periodDate = periodDateSupplier.get();
+          periodDate = periodDateSupplier.get().orElse(Long.MAX_VALUE);
         }
-        json.prop("isNew", periodDate.isPresent() && line.getScmDate() > periodDate.get());
+        json.prop("isNew", line.getScmDate() > periodDate);
       }
       json.endObject();
     }