From a352538afc0f97ae8990d04de27deb84c7022689 Mon Sep 17 00:00:00 2001 From: Pat Whelan Date: Wed, 30 Oct 2024 10:10:09 -0400 Subject: [PATCH] rethrow Errors --- .../external/amazonbedrock/AmazonBedrockInferenceClient.java | 2 ++ .../amazonbedrock/AmazonBedrockStreamingChatProcessor.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockInferenceClient.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockInferenceClient.java index 0533da32828bc..bd03909db380c 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockInferenceClient.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockInferenceClient.java @@ -23,6 +23,7 @@ import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.SpecialPermission; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.xcontent.ChunkedToXContent; @@ -101,6 +102,7 @@ public Flow.Publisher converseStream(ConverseStream } private void onFailure(ActionListener listener, Throwable t, String method) { + ExceptionsHelper.maybeDieOnAnotherThread(t); var unwrappedException = t; if (t instanceof CompletionException || t instanceof ExecutionException) { unwrappedException = t.getCause() != null ? t.getCause() : t; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockStreamingChatProcessor.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockStreamingChatProcessor.java index e749b35464b95..33e756b75c339 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockStreamingChatProcessor.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/amazonbedrock/AmazonBedrockStreamingChatProcessor.java @@ -12,6 +12,7 @@ import software.amazon.awssdk.services.bedrockruntime.model.ConverseStreamResponseHandler; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.core.Strings; import org.elasticsearch.logging.LogManager; @@ -89,6 +90,7 @@ private void sendDownstreamOnAnotherThread(ContentBlockDeltaEvent event) { @Override public void onError(Throwable amazonBedrockRuntimeException) { + ExceptionsHelper.maybeDieOnAnotherThread(amazonBedrockRuntimeException); error.set( new ElasticsearchException( Strings.format("AmazonBedrock StreamingChatProcessor failure: [%s]", amazonBedrockRuntimeException.getMessage()),