diff options
author | David Pursehouse <dpursehouse@collab.net> | 2017-03-14 16:32:28 +0900 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2017-03-14 16:37:47 +0900 |
commit | 07d7f65fedd897880b5a6bd23bac22c80f6a2e37 (patch) | |
tree | 68a831a20e83e5e2e85b0b90e1dddbee9af08e07 | |
parent | 03ee3f6130f5411dcfce5ef23a0bcf6e0aa689d9 (diff) |
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
-rw-r--r-- | gerrit-sshd/src/main/java/com/google/gerrit/sshd/plugin/LfsPluginAuthCommand.java | 13 |
1 files 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<String> 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)); |