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

Poc classloader in policies problem #13619

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.mule.runtime.api.util.MuleSystemProperties.MULE_LOGGING_BLOCKING_CATEGORIES;
import static org.mule.runtime.core.api.processor.ReactiveProcessor.ProcessingType.BLOCKING;
import static org.mule.runtime.core.api.processor.ReactiveProcessor.ProcessingType.CPU_LITE;
import static org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader;
import static org.mule.runtime.core.api.util.StringUtils.EMPTY;

import static java.util.Arrays.asList;
Expand All @@ -23,6 +24,7 @@
import org.mule.runtime.core.api.el.ExtendedExpressionManager;
import org.mule.runtime.core.api.event.CoreEvent;
import org.mule.runtime.core.api.processor.Processor;
import org.mule.runtime.core.api.util.ClassUtils;
import org.mule.runtime.core.api.util.StringUtils;
import org.mule.runtime.core.internal.interception.HasParamsAsTemplateProcessor;

Expand Down Expand Up @@ -56,6 +58,7 @@ public class LoggerMessageProcessor extends AbstractComponent
ExtendedExpressionManager expressionManager;

private volatile ProcessingType processingType;
private transient ClassLoader loggerExecutionClassloader;

@Override
public void initialise() throws InitialisationException {
Expand All @@ -65,6 +68,7 @@ public void initialise() throws InitialisationException {
}

protected void initLogger() {
this.loggerExecutionClassloader = Thread.currentThread().getContextClassLoader();
if (category != null) {
logger = LoggerFactory.getLogger(category);
} else {
Expand Down Expand Up @@ -104,6 +108,14 @@ private boolean isBlocking(String category) {
}

protected void log(CoreEvent event) {
if (loggerExecutionClassloader != null) {
withContextClassLoader(loggerExecutionClassloader, () -> doLog(event));
} else {
doLog(event);
}
}

private void doLog(CoreEvent event) {
if (event == null) {
logWithLevel(null);
} else {
Expand Down