aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi/src
diff options
context:
space:
mode:
authorZipeng WU <zipeng.wu@sonarsource.com>2020-12-08 16:31:40 +0100
committersonartech <sonartech@sonarsource.com>2020-12-09 20:07:21 +0000
commit99afeb0ec5899418eec90c2370230d03855b86c1 (patch)
treee4f87cbfd287f7f67d7ac9aa4804d69867c62658 /server/sonar-webserver-webapi/src
parentd165357c146efcc588bcac671f7f7ae7a5313d12 (diff)
downloadsonarqube-99afeb0ec5899418eec90c2370230d03855b86c1.tar.gz
sonarqube-99afeb0ec5899418eec90c2370230d03855b86c1.zip
should not assign null when using Optional
Diffstat (limited to 'server/sonar-webserver-webapi/src')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java
index 64bf8ebacdf..225e6fcdd1c 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java
@@ -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();
}