Skip to content

Commit

Permalink
Fix non-unique module handler identifiers (#3592)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K authored May 5, 2023
1 parent d7ba8ad commit 28ec419
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected Map<String, ModuleHandler> getHandlers() {
@Override
@SuppressWarnings("null")
public @Nullable ModuleHandler getHandler(Module module, String ruleUID) {
String id = ruleUID + module.getId();
String id = getModuleIdentifier(ruleUID, module.getId());
ModuleHandler handler = handlers.get(id);
handler = handler == null ? internalCreate(module, ruleUID) : handler;
if (handler != null) {
Expand All @@ -80,8 +80,12 @@ protected Map<String, ModuleHandler> getHandlers() {

@Override
public void ungetHandler(Module module, String ruleUID, ModuleHandler handler) {
if (handlers.remove(ruleUID + module.getId(), handler)) {
if (handlers.remove(getModuleIdentifier(ruleUID, module.getId()), handler)) {
handler.dispose();
}
}

protected String getModuleIdentifier(String ruleUid, String moduleId) {
return ruleUid + "$" + moduleId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Collection<String> getTypes() {
@SuppressWarnings({ "unchecked" })
@Override
public void ungetHandler(Module module, String childModulePrefix, ModuleHandler handler) {
ModuleHandler handlerOfModule = getHandlers().get(childModulePrefix + module.getId());
ModuleHandler handlerOfModule = getHandlers().get(getModuleIdentifier(childModulePrefix, module.getId()));
if (handlerOfModule instanceof AbstractCompositeModuleHandler) {
AbstractCompositeModuleHandler<ModuleImpl, ?, ?> h = (AbstractCompositeModuleHandler<ModuleImpl, ?, ?>) handlerOfModule;
Set<ModuleImpl> modules = h.moduleHandlerMap.keySet();
Expand Down

0 comments on commit 28ec419

Please sign in to comment.