diff options
author | David Ostrovsky <david@ostrovsky.org> | 2013-09-06 19:01:00 +0200 |
---|---|---|
committer | David Ostrovsky <david.ostrovsky@gmail.com> | 2013-09-18 18:38:33 +0000 |
commit | 6b12b35d2a6aa151e9cafe9a052b5f6f2ced7211 (patch) | |
tree | cb1a27f66c3129ce04771855e5f7a4f599608651 | |
parent | 640b95cf1b26795e2cb6013499f0d59be4dc0767 (diff) |
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
-rw-r--r-- | gerrit-sshd/src/main/java/com/google/gerrit/sshd/DispatchCommandProvider.java | 10 |
1 files 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<DispatchCommand> { 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<DispatchCommand> { public RegistrationHandle replace(final CommandName name, final Provider<Command> cmd) { final ConcurrentMap<String, CommandProvider> 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); } }; } |