Fix installation of plugins
e51c428fe5
broke the unregistering of plugin owned SSH command by passing wrong instance to the ConcurrentMap.remove() function.bae9e58ddd
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,bae9e58ddd
didn't fix all places: the same bug in unregistering of SSH commands in DispatchCommandProvider.replace() method wasn't fixed. Change-Id: I21132d4f7aec58347acbf50d75a962cb8251201f
This commit is contained in:
parent
640b95cf1b
commit
6b12b35d2a
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user