Skip to content

Commit 90171f3

Browse files
Rethrow exception in writeData (#943) (#945)
(cherry picked from commit 31fae14) Signed-off-by: Louis Chu <clingzhi@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent b831d1e commit 90171f3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

flint-core/src/main/java/org/opensearch/flint/core/IRestHighLevelClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ static void recordLatency(String metricNamePrefix, long latencyMilliseconds) {
9898
* Otherwise, it increments a general failure metric counter based on the status code category (e.g., 4xx, 5xx).
9999
*
100100
* @param metricNamePrefix the prefix for the metric name which is used to construct the full metric name for failure
101-
* @param e the exception encountered during the operation, used to determine the type of failure
101+
* @param t the exception encountered during the operation, used to determine the type of failure
102102
*/
103-
static void recordOperationFailure(String metricNamePrefix, Exception e) {
104-
OpenSearchException openSearchException = extractOpenSearchException(e);
103+
static void recordOperationFailure(String metricNamePrefix, Throwable t) {
104+
OpenSearchException openSearchException = extractOpenSearchException(t);
105105
int statusCode = openSearchException != null ? openSearchException.status().getStatus() : 500;
106106
if (openSearchException != null) {
107107
CustomLogging.logError(new OperationMessage("OpenSearch Operation failed.", statusCode), openSearchException);
108108
} else {
109-
CustomLogging.logError("OpenSearch Operation failed with an exception.", e);
109+
CustomLogging.logError("OpenSearch Operation failed with an exception.", t);
110110
}
111111
if (statusCode == 403) {
112112
String forbiddenErrorMetricName = metricNamePrefix + ".403.count";

spark-sql-application/src/main/scala/org/apache/spark/sql/FlintJobExecutor.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ trait FlintJobExecutor {
168168
IRestHighLevelClient.recordOperationSuccess(
169169
MetricConstants.RESULT_METADATA_WRITE_METRIC_PREFIX)
170170
} catch {
171-
case e: Exception =>
171+
case t: Throwable =>
172172
IRestHighLevelClient.recordOperationFailure(
173173
MetricConstants.RESULT_METADATA_WRITE_METRIC_PREFIX,
174-
e)
174+
t)
175+
// Re-throw the exception
176+
throw t
175177
}
176178
}
177179

0 commit comments

Comments
 (0)