From cf95293810c518bc43e4cd0e1c5e5d32c1248292 Mon Sep 17 00:00:00 2001 From: Xavier Bai Date: Fri, 20 Dec 2024 11:29:54 +0800 Subject: [PATCH] [AMORO-3367] Avoid throwing StringIndexOutOfBoundsException in flink optimizer executors (#3368) Co-authored-by: ZhouJinsong --- .../apache/amoro/optimizer/flink/FlinkOptimizerExecutor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/amoro-optimizer/amoro-optimizer-flink/src/main/java/org/apache/amoro/optimizer/flink/FlinkOptimizerExecutor.java b/amoro-optimizer/amoro-optimizer-flink/src/main/java/org/apache/amoro/optimizer/flink/FlinkOptimizerExecutor.java index 824a73b59f..cb2fff27e0 100644 --- a/amoro-optimizer/amoro-optimizer-flink/src/main/java/org/apache/amoro/optimizer/flink/FlinkOptimizerExecutor.java +++ b/amoro-optimizer/amoro-optimizer-flink/src/main/java/org/apache/amoro/optimizer/flink/FlinkOptimizerExecutor.java @@ -75,8 +75,9 @@ protected OptimizingTaskResult executeTask(OptimizingTask task) { if (runtimeContext != null && !runtimeContext.isEmpty()) { runtimeContext.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n")); } + String errorMsg = sb + result.getErrorMessage(); result.setErrorMessage( - (sb + result.getErrorMessage()).substring(0, ERROR_MESSAGE_MAX_LENGTH)); + errorMsg.substring(0, Math.min(ERROR_MESSAGE_MAX_LENGTH, errorMsg.length()))); } return result; }