Skip to content

Commit

Permalink
Check channel type
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Oct 4, 2023
1 parent e001924 commit b77e678
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,21 @@ public SecurityRestFilter(
*/
public RestHandler wrap(RestHandler original, AdminDNs adminDNs) {
return (request, channel, client) -> {
Channel nettyChannel = ((Netty4HttpChannel) request.getHttpChannel()).getNettyChannel();
final RestResponse earlyResponse = nettyChannel.attr(EARLY_RESPONSE).get();
final ThreadContext.StoredContext storedContext = nettyChannel.attr(CONTEXT_TO_RESTORE).get();
nettyChannel.attr(CONTEXT_TO_RESTORE).set(null);
nettyChannel.attr(EARLY_RESPONSE).set(null);

if (earlyResponse != null) {
channel.sendResponse(earlyResponse);
return;
}
if (request.getHttpChannel() instanceof Netty4HttpChannel) {
Channel nettyChannel = ((Netty4HttpChannel) request.getHttpChannel()).getNettyChannel();
final RestResponse earlyResponse = nettyChannel.attr(EARLY_RESPONSE).get();
final ThreadContext.StoredContext storedContext = nettyChannel.attr(CONTEXT_TO_RESTORE).get();
nettyChannel.attr(CONTEXT_TO_RESTORE).set(null);
nettyChannel.attr(EARLY_RESPONSE).set(null);

if (earlyResponse != null) {
channel.sendResponse(earlyResponse);
return;
}

if (storedContext != null) {
storedContext.restore();
if (storedContext != null) {
storedContext.restore();
}
}

org.apache.logging.log4j.ThreadContext.clearAll();
Expand Down

0 comments on commit b77e678

Please sign in to comment.