Fix thread-unsafe command unregistration (#583)

Access to the dispatcher is guarded by `lock`.
This commit is contained in:
Hugo Manrique
2021-10-04 21:17:36 +02:00
committed by GitHub
parent aa210b3544
commit 567582b2e2

View File

@@ -143,9 +143,14 @@ public class VelocityCommandManager implements CommandManager {
@Override
public void unregister(final String alias) {
Preconditions.checkNotNull(alias, "alias");
lock.writeLock().lock();
try {
// The literals of secondary aliases will preserve the children of
// the removed literal in the graph.
dispatcher.getRoot().removeChildByName(alias.toLowerCase(Locale.ENGLISH));
} finally {
lock.writeLock().unlock();
}
}
/**