diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java index 0d98587177ca..e1426fc8b56d 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java @@ -142,11 +142,21 @@ private CloseableIterator collect(TableResult result, int timeout) { return; } } catch (Exception e) { + // If we can't get job status, assume the job has terminated. + // This handles cases where MiniCluster has already shut down. + // Similar to Flink's CollectResultFetcher behavior. + return; + } + } + // Only cancel if job is not already terminated + try { + if (!client.getJobStatus().get().isGloballyTerminalState()) { client.cancel(); - throw new RuntimeException(e); } + } catch (Exception e) { + // If we can't check status or cancel, assume job has terminated. + // This handles IllegalStateException when MiniCluster is shut down. } - client.cancel(); }); timeoutThread.start(); return result.collect();