jubins commented on code in PR #28332:
URL: https://github.com/apache/flink/pull/28332#discussion_r3425708337
##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/experimental/SocketStreamIteratorTest.java:
##########
@@ -104,4 +104,45 @@ public void run() {
.isInstanceOf(RuntimeException.class)
.hasMessageContaining("test");
}
+
+ @Test
+ void testNotifyOfErrorBeforeConnection() throws Exception {
+ // Test that notifyOfError() can be called before connectedSocket is
initialized
+ // (i.e., before any data has been read)
+ final SocketStreamIterator<Long> iterator =
+ new SocketStreamIterator<>(LongSerializer.INSTANCE);
+
+ // Call notifyOfError before any connection is established
+ // This should not throw NullPointerException
+ iterator.notifyOfError(new Exception("early error"));
+
+ // Verify that the iterator properly propagates the error
+ assertThatThrownBy(iterator::hasNext)
+ .isInstanceOf(RuntimeException.class)
+ .hasMessageContaining("early error");
+
+ // Clean up
+ iterator.close();
+ }
+
+ @Test
+ void testNotifyOfErrorMultipleTimes() throws Exception {
+ // Test that notifyOfError() handles multiple calls gracefully
+ final SocketStreamIterator<Long> iterator =
+ new SocketStreamIterator<>(LongSerializer.INSTANCE);
+
+ // First error should be recorded
+ iterator.notifyOfError(new Exception("first error"));
+
+ // Second error should be ignored (first error takes precedence)
+ iterator.notifyOfError(new Exception("second error"));
Review Comment:
good point, added `.hasMessageNotContaining("second error")` to the
assertion chain in `testNotifyOfErrorMultipleTimes`. Now the test explicitly
verifies both that the first error is propagated and that the second error did
not overwrite it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]