Skip to content

Commit

Permalink
Handle exception
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Oct 3, 2023
1 parent aa5c0fc commit 868ec9b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import org.opensearch.security.support.ConfigConstants;
import org.opensearch.security.ssl.OpenSearchSecuritySSLPlugin;
import org.opensearch.common.settings.Settings;
import org.opensearch.OpenSearchSecurityException;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestResponse;

import java.util.regex.Matcher;

Expand Down Expand Up @@ -103,6 +106,10 @@ public void channelRead0(ChannelHandlerContext ctx, DefaultHttpRequest msg) thro
} else {
ctx.channel().attr(SHOULD_DECOMPRESS).set(Boolean.TRUE);
}
} catch (OpenSearchSecurityException e) {
RestResponse earlyResponse = new BytesRestResponse(interceptingRestChannel, e);
ctx.channel().attr(EARLY_RESPONSE).set(earlyResponse);
ctx.channel().attr(SHOULD_DECOMPRESS).set(Boolean.FALSE);
} finally {
ctx.fireChannelRead(msg);
}
Expand Down

0 comments on commit 868ec9b

Please sign in to comment.