diff options
author | Rikard Almgren <rikardal@axis.com> | 2018-09-20 12:58:18 +0200 |
---|---|---|
committer | Rikard Almgren <rikardal@axis.com> | 2018-09-20 13:56:00 +0200 |
commit | f27d738684c9d223a143ba6ebd54c45bab807347 (patch) | |
tree | b9e495cdd24ce2fb5d132d3893334d69b36b7ee9 | |
parent | cbb7843d10836bc0e8af34c37c70e9df7ef6cc96 (diff) |
Change sshd.requestLog to use event.reject(ConfigKey)
If a non-boolean is entered into the config when
reloading, the change is rejected.
This change is dependent on Id481240f01dbd70df401445069bcba98ad8f98d3
Change-Id: I1e0ce43d0acd4c8e36e37b3fe64a21b4f1740447
-rw-r--r-- | java/com/google/gerrit/sshd/SshLog.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/java/com/google/gerrit/sshd/SshLog.java b/java/com/google/gerrit/sshd/SshLog.java index 98c649d3db..216c29f575 100644 --- a/java/com/google/gerrit/sshd/SshLog.java +++ b/java/com/google/gerrit/sshd/SshLog.java @@ -323,16 +323,20 @@ class SshLog implements LifecycleListener, GerritConfigListener { if (!event.isValueUpdated(sshdRequestLog)) { return Collections.emptyList(); } - - boolean enabled = event.getNewConfig().getBoolean("sshd", "requestLog", true); boolean stateUpdated; - if (enabled) { - stateUpdated = enableLogging(); - } else { - stateUpdated = disableLogging(); + try { + boolean enabled = event.getNewConfig().getBoolean("sshd", "requestLog", true); + + if (enabled) { + stateUpdated = enableLogging(); + } else { + stateUpdated = disableLogging(); + } + return stateUpdated + ? Collections.singletonList(event.accept(sshdRequestLog)) + : Collections.emptyList(); + } catch (IllegalArgumentException iae) { + return Collections.singletonList(event.reject(sshdRequestLog)); } - return stateUpdated - ? Collections.singletonList(event.accept(sshdRequestLog)) - : Collections.emptyList(); } } |