Skip to content

Commit

Permalink
Keep exception block
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks committed Aug 21, 2024
1 parent 9d7938b commit dbc0dd9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.core.xcontent.XContentHelper;
import org.opensearch.index.engine.VersionConflictEngineException;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestChannel;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.RestRequest.Method;
Expand Down Expand Up @@ -603,12 +604,17 @@ protected final RestChannelConsumer prepareRequest(RestRequest request, NodeClie
return channel -> threadPool.generic().submit(() -> {
try {
threadPool.getThreadContext().putHeader(ConfigConstants.OPENDISTRO_SECURITY_CONF_REQUEST_HEADER, "true");

requestHandlers = Optional.ofNullable(requestHandlers).orElseGet(requestHandlersBuilder::build);
final var requestHandler = requestHandlers.getOrDefault(request.method(), methodNotImplementedHandler);
requestHandler.handle(channel, request, client);
} catch (IOException e) {
} catch (Exception e) {
LOGGER.error("Error processing request {}", request, e);
throw ExceptionsHelper.convertToOpenSearchException(e);
try {
channel.sendResponse(new BytesRestResponse(channel, e));
} catch (IOException ioe) {
throw ExceptionsHelper.convertToOpenSearchException(e);
}
}
});
}
Expand Down

0 comments on commit dbc0dd9

Please sign in to comment.