Skip to content

Commit 2b199b0

Browse files
committed
[hotfix] Harden KafkaWriterFaultToleranceITCase
Make sure that TimeoutExceptions are also valid instead of NetworkExceptions.
1 parent 91b048d commit 2b199b0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/sink/KafkaWriterFaultToleranceITCase.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ void testWriteExceptionWhenKafkaUnavailable() throws Exception {
6868
writer.getCurrentProducer().flush();
6969
assertThatCode(() -> writer.write(1, SINK_WRITER_CONTEXT))
7070
.rootCause()
71-
.matches(
72-
e ->
73-
e instanceof NetworkException
74-
|| e instanceof TimeoutException);
71+
.isInstanceOfAny(NetworkException.class, TimeoutException.class);
7572
} finally {
7673
KAFKA_CONTAINER.start();
7774
}
@@ -91,7 +88,8 @@ void testFlushExceptionWhenKafkaUnavailable() throws Exception {
9188
KAFKA_CONTAINER.stop();
9289
try {
9390
assertThatCode(() -> writer.flush(false))
94-
.hasRootCauseExactlyInstanceOf(NetworkException.class);
91+
.rootCause()
92+
.isInstanceOfAny(NetworkException.class, TimeoutException.class);
9593
} finally {
9694
KAFKA_CONTAINER.start();
9795
}
@@ -115,7 +113,8 @@ void testCloseExceptionWhenKafkaUnavailable() throws Exception {
115113
writer.getCurrentProducer().flush();
116114
// closing producer resource throws exception first
117115
assertThatCode(() -> writer.close())
118-
.hasRootCauseExactlyInstanceOf(NetworkException.class);
116+
.rootCause()
117+
.isInstanceOfAny(NetworkException.class, TimeoutException.class);
119118
} catch (Exception e) {
120119
writer.close();
121120
throw e;

0 commit comments

Comments
 (0)