Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOGMGR-324] Let initializer enable strong node refs #387

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/jboss/logmanager/LogContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ private static void addStrong(Map<String, Reference<Level, Void>> map, Level lev
final ReentrantLock treeLock = new ReentrantLock();

LogContext(final boolean strong, LogContextInitializer initializer) {
this.strong = strong;
this.initializer = initializer;
this.strong = strong || initializer.useStrongReferences();
levelMapReference = new AtomicReference<Map<String, Reference<Level, Void>>>(LazyHolder.INITIAL_LEVEL_MAP);
rootLogger = new LoggerNode(this);
closeHandlers = new LinkedHashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,13 @@ default Level getMinimumLevel(String loggerName) {
default Handler[] getInitialHandlers(String loggerName) {
return NO_HANDLERS;
}

/**
* Establish whether strong references should be used for logger nodes.
*
* @return {@code true} to use strong references, or {@code false} to use weak references
*/
default boolean useStrongReferences() {
return false;
}
}