Skip to content

Commit

Permalink
Merge pull request #420 from dmlloyd/handlers
Browse files Browse the repository at this point in the history
[LOGMGR-332] Allow handlers to be reinitialized in native image
  • Loading branch information
jamezp authored Jul 26, 2023
2 parents 5bd68f4 + 27ebbe1 commit 70480dd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/org/jboss/logmanager/LoggerNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,31 @@ boolean isLoggableLevel(int level) {
}

Handler[] getHandlers() {
Handler[] handlers = this.handlers;
if (handlers == null) {
synchronized (this) {
handlers = this.handlers;
if (handlers == null) {
handlers = this.handlers = safeCloneHandlers(context.getInitializer().getInitialHandlers(fullName));
}
}
}
return handlers;
}

Handler[] clearHandlers() {
final Handler[] handlers = this.handlers;
handlersUpdater.clear(this);
return handlers.length > 0 ? handlers.clone() : handlers;
return safeCloneHandlers(handlers);
}

void removeHandler(final Handler handler) {
getHandlers();
handlersUpdater.remove(this, handler, true);
}

void addHandler(final Handler handler) {
getHandlers();
handlersUpdater.add(this, handler);
context.pin(this);
}
Expand Down Expand Up @@ -418,7 +429,7 @@ void setUseParentHandlers(final boolean useParentHandlers) {
}

void publish(final ExtLogRecord record) {
for (Handler handler : handlers)
for (Handler handler : getHandlers())
try {
handler.publish(record);
} catch (VirtualMachineError e) {
Expand Down

0 comments on commit 70480dd

Please sign in to comment.