in src/main/java/com/googlesource/gerrit/plugins/hooks/HookExecutor.java [54:77]
HookResult submit(String projectName, Path hook, HookArgs args) {
if (!Files.exists(hook)) {
logger.atFine().log("Hook file not found: %s", hook);
return null;
}
HookTask.Sync hookTask = new HookTask.Sync(projectName, hook, args);
FutureTask<HookResult> task = new FutureTask<>(hookTask);
threadPool.execute(task);
String message;
try {
return task.get(timeout, TimeUnit.SECONDS);
} catch (TimeoutException e) {
message = "Synchronous hook timed out " + hook;
logger.atSevere().log(message);
} catch (Exception e) {
message = "Error running hook " + hook;
logger.atSevere().withCause(e).log(message);
}
task.cancel(true);
hookTask.cancel();
return new HookResult(hookTask.getOutput(), message);
}