Annotate methods that return a definitely null value with @Nullable
We intend to enable the ReturnMissingNullable errorprone pattern in
Gerrit core and this fixes the current issues.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I54c8620db01774d2043cdd113d342222f89a12e9
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java
index 4e74ece..e89c05e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.hooks;
+import com.google.gerrit.common.Nullable;
import java.nio.file.Path;
class AsynchronousHook extends Hook {
@@ -24,12 +25,14 @@
this.queue = queue;
}
+ @Nullable
@Override
HookResult execute(HookArgs args) {
queue.submit(path, args);
return null;
}
+ @Nullable
@Override
HookResult execute(String projectName, HookArgs args) {
queue.submit(projectName, path, args);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java
index 5b642d3..e83fd4a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java
@@ -16,6 +16,7 @@
import com.google.common.flogger.FluentLogger;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.logging.LoggingContextAwareExecutorService;
@@ -51,6 +52,7 @@
return submit(null, hook, args);
}
+ @Nullable
HookResult submit(String projectName, Path hook, HookArgs args) {
if (!Files.exists(hook)) {
logger.atFine().log("Hook file not found: %s", hook);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java
index 02dfd08..b7a0784 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java
@@ -18,6 +18,7 @@
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteStreams;
+import com.google.gerrit.common.Nullable;
import com.google.gerrit.entities.Project;
import com.google.gerrit.metrics.Timer1;
import java.io.BufferedReader;
@@ -78,6 +79,7 @@
return hook.getFileName().toString();
}
+ @Nullable
public String getOutput() {
return output != null ? output.toString() : null;
}