Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -133,6 +134,7 @@ public static ContextHandler getContextHandler(Request request)
private final MimeTypes.Wrapper _mimeTypes = new MimeTypes.Wrapper();
private final List<ContextScopeListener> _contextListeners = new CopyOnWriteArrayList<>();
private final List<VHost> _vhosts = new ArrayList<>();
private final AtomicBoolean _enterScopeSetClassloaderFailed = new AtomicBoolean();

private String _displayName;
private String _contextPath = "/";
Expand Down Expand Up @@ -634,8 +636,12 @@ protected ClassLoader enterScope(Request contextRequest)
}
catch (Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("error setting a context classloader on thread {}", Thread.currentThread(), x);
// Log as warning the first time it happens.
String msg = "Error setting a context classloader on thread {}";
if (_enterScopeSetClassloaderFailed.compareAndSet(false, true))
LOG.warn(msg, Thread.currentThread(), x);
else if (LOG.isDebugEnabled())
LOG.debug(msg, Thread.currentThread(), x);
}
}
notifyEnterScope(contextRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public boolean handle(Request request, Response response, Callback callback) thr
@Override
public void run()
{
try (Blocker.Callback cb = Blocker.callback())
try (StacklessLogging ignore = new StacklessLogging(ContextHandler.class);
Blocker.Callback cb = Blocker.callback())
{
// When a classloader is configured, Response.write() tries to set it as the context classloader.
response.write(true, ByteBuffer.allocate(32), cb);
Expand All @@ -209,6 +210,12 @@ public void run()
}
}

@Override
public ClassLoader getContextClassLoader()
{
return null;
}

@Override
public void setContextClassLoader(ClassLoader cl)
{
Expand Down Expand Up @@ -258,7 +265,8 @@ public boolean handle(Request request, Response response, Callback callback) thr
@Override
public void completed(Integer result, Object attachment)
{
try (Blocker.Callback cb = Blocker.callback())
try (StacklessLogging ignore = new StacklessLogging(ContextHandler.class);
Blocker.Callback cb = Blocker.callback())
{
// When a classloader is configured, Response.write() tries to set it as the context classloader.
response.write(true, ByteBuffer.allocate(32), cb);
Expand Down