diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/DispatchCommandProvider.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/DispatchCommandProvider.java index c7594bc6d1..ce1da95fed 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/DispatchCommandProvider.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/DispatchCommandProvider.java @@ -60,10 +60,7 @@ public class DispatchCommandProvider implements Provider { return new RegistrationHandle() { @Override public void remove() { - if (!m.remove(name.value(), commandProvider)) { - throw new IllegalStateException(String.format( - "can not unregister command: %s", name.value())); - } + m.remove(name.value(), commandProvider); } }; } @@ -71,11 +68,12 @@ public class DispatchCommandProvider implements Provider { public RegistrationHandle replace(final CommandName name, final Provider cmd) { final ConcurrentMap m = getMap(); - m.put(name.value(), new CommandProvider(cmd, null)); + final CommandProvider commandProvider = new CommandProvider(cmd, null); + m.put(name.value(), commandProvider); return new RegistrationHandle() { @Override public void remove() { - m.remove(name.value(), cmd); + m.remove(name.value(), commandProvider); } }; }