From 6b12b35d2a6aa151e9cafe9a052b5f6f2ced7211 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Fri, 6 Sep 2013 19:01:00 +0200 Subject: Fix installation of plugins e51c428fe5ef3960f4990e1c0471d067783d4718 broke the unregistering of plugin owned SSH command by passing wrong instance to the ConcurrentMap.remove() function. bae9e58ddd68992473307787fb01e022f5969fee was trying to fix it, but broke it for the installation of plugins by throwing the `IllegalStateException` in case the old registration handle wasn't found. But it's perfectly possible and even wanted during plugin reloading: registration handle is replaced and the old one cannot be found. Moreover, bae9e58ddd68992473307787fb01e022f5969fee didn't fix all places: the same bug in unregistering of SSH commands in DispatchCommandProvider.replace() method wasn't fixed. Change-Id: I21132d4f7aec58347acbf50d75a962cb8251201f --- .../java/com/google/gerrit/sshd/DispatchCommandProvider.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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); } }; } -- cgit v1.2.3