From 07d7f65fedd897880b5a6bd23bac22c80f6a2e37 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 14 Mar 2017 16:32:28 +0900 Subject: [PATCH] LfsPluginAuthCommand: Don't spam error log when LFS plugin is missing The LfsPluginAuthCommand is only installed when lfs.plugin is set in the gerrit.config file. However, if the corresponding plugin is not actually installed, or it does not provide the command implementation, Failure is thrown which results in a stack trace being emitted to the log on every ssh push operation. Change it to throw UnloggedFailure, and write a less verbose message to the log at warn level. This will still be emitted to the log on every ssh push, but it's less noisy than before. Change-Id: Ie638bda96ddbac173eccd74f9f6a25ed87c778c8 --- .../gerrit/sshd/plugin/LfsPluginAuthCommand.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/plugin/LfsPluginAuthCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/plugin/LfsPluginAuthCommand.java index 0c8d024f1a..3f4ca616d0 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/plugin/LfsPluginAuthCommand.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/plugin/LfsPluginAuthCommand.java @@ -24,11 +24,18 @@ import com.google.inject.Provider; import org.eclipse.jgit.lib.Config; import org.kohsuke.args4j.Argument; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; public class LfsPluginAuthCommand extends SshCommand { + private static final Logger log = + LoggerFactory.getLogger(LfsPluginAuthCommand.class); + private static final String CONFIGURATION_ERROR = "Server configuration error:" + + " LFS auth over SSH is not properly configured."; + public interface LfsSshPluginAuth { String authenticate(CurrentUser user, List args) throws UnloggedFailure, Failure; @@ -65,11 +72,11 @@ public class LfsPluginAuthCommand extends SshCommand { } @Override - protected void run() throws UnloggedFailure, Failure, Exception { + protected void run() throws UnloggedFailure, Exception { LfsSshPluginAuth pluginAuth = auth.get(); if (pluginAuth == null) { - throw new Failure(1, "Server configuration error:" - + " LFS auth over SSH is not properly configured."); + log.warn(CONFIGURATION_ERROR); + throw new UnloggedFailure(1, CONFIGURATION_ERROR); } stdout.print(pluginAuth.authenticate(user.get(), args));