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; }