From 34a69b910a0bd2313e3614adf0407d3a137181eb Mon Sep 17 00:00:00 2001 From: shekharrajak Date: Sun, 28 Dec 2025 20:05:40 +0530 Subject: [PATCH] Fix unstable test: handle MiniCluster shutdown gracefully in collect method --- .../flink/PrimaryKeyFileStoreTableITCase.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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();