public final class RequestContextUtil extends Object
RequestContext.| Modifier and Type | Method and Description |
|---|---|
static IllegalStateException |
newIllegalContextPushingException(RequestContext newCtx,
RequestContext oldCtx)
Returns an
IllegalStateException which is raised when pushing a context from
the unexpected thread or forgetting to close the previous context. |
static SafeCloseable |
noopSafeCloseable()
Returns the
SafeCloseable which doesn't do anything. |
static SafeCloseable |
pop()
Removes the
RequestContext in the thread-local if exists and returns SafeCloseable which
pushes the RequestContext back to the thread-local. |
public static SafeCloseable noopSafeCloseable()
SafeCloseable which doesn't do anything.public static IllegalStateException newIllegalContextPushingException(RequestContext newCtx, RequestContext oldCtx)
IllegalStateException which is raised when pushing a context from
the unexpected thread or forgetting to close the previous context.public static SafeCloseable pop()
RequestContext in the thread-local if exists and returns SafeCloseable which
pushes the RequestContext back to the thread-local.
Because this method pops the RequestContext arbitrarily, it shouldn't be used in
most cases. One of the examples this can be used is in ChannelFutureListener.
The ChannelFuture can be complete when the eventloop handles the different request. The
eventloop might have the wrong RequestContext in the thread-local, so we should pop it.
Copyright © 2020 LeanCloud. All rights reserved.