Adapt to enabling error level for the UnnecessaryLambda bug pattern
Fix the current issues so that the build continues to work.
Bug: Issue 15082
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I306b33bb26801e971acd609b970a022594275113
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 6e5ada5..6f2fade 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java
@@ -20,7 +20,6 @@
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.logging.LoggingContextAwareExecutorService;
import com.google.inject.Inject;
-import java.lang.Thread.UncaughtExceptionHandler;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ExecutorService;
@@ -33,10 +32,6 @@
public class HookExecutor implements LifecycleListener {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- private static final UncaughtExceptionHandler LOG_UNCAUGHT_EXCEPTION =
- (t, e) ->
- logger.atSevere().withCause(e).log("HookExecutor thread %s threw exception", t.getName());
-
private final ExecutorService threadPool;
private final int timeout;
@@ -48,7 +43,7 @@
Executors.newCachedThreadPool(
new ThreadFactoryBuilder()
.setNameFormat("SyncHook-%d")
- .setUncaughtExceptionHandler(LOG_UNCAUGHT_EXCEPTION)
+ .setUncaughtExceptionHandler(HookExecutor::logUncaughtException)
.build()));
}
@@ -96,4 +91,8 @@
}
} while (!isTerminated);
}
+
+ private static void logUncaughtException(Thread t, Throwable e) {
+ logger.atSevere().withCause(e).log("HookExecutor thread %s threw exception", t.getName());
+ }
}