Skip to content

Commit 2a87032

Browse files
committed
Explanatory comments
1 parent ef1f0ef commit 2a87032

File tree

1 file changed

+10
-2
lines changed
  • libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy

1 file changed

+10
-2
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ public <E extends Entitlement> Stream<E> getEntitlements(Class<E> entitlementCla
100100
}
101101
}
102102

103-
private static final ConcurrentHashMap<String, Logger> MODULE_LOGGERS = new ConcurrentHashMap<>();
104-
105103
private FileAccessTree getDefaultFileAccess(String componentName, Path componentPath) {
106104
return FileAccessTree.of(componentName, UNKNOWN_COMPONENT_NAME, FilesEntitlement.EMPTY, pathLookup, componentPath, List.of());
107105
}
@@ -580,6 +578,16 @@ private static Logger getLogger(String componentName, String moduleName) {
580578
return MODULE_LOGGERS.computeIfAbsent(PolicyManager.class.getName() + loggerSuffix, LogManager::getLogger);
581579
}
582580

581+
/**
582+
* We want to use the same {@link Logger} object for a given name, because we want {@link ModuleEntitlements}
583+
* {@code equals} and {@code hashCode} to work.
584+
* <p>
585+
* This would not be required if LogManager
586+
* <a href="https://github.com/elastic/elasticsearch/issues/87511">memoized the loggers</a>,
587+
* but here we are.
588+
*/
589+
private static final ConcurrentHashMap<String, Logger> MODULE_LOGGERS = new ConcurrentHashMap<>();
590+
583591
public void checkManageThreadsEntitlement(Class<?> callerClass) {
584592
checkEntitlementPresent(callerClass, ManageThreadsEntitlement.class);
585593
}

0 commit comments

Comments
 (0)