tashoyan commented on a change in pull request #17765:
URL: https://github.com/apache/flink/pull/17765#discussion_r777689068
##########
File path:
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/KafkaConsumerTestBase.java
##########
@@ -355,6 +352,24 @@ public void run() {
};
runner.start();
+ Thread.sleep(2 * 1000L);
Review comment:
Is this an accepted way of thread synchronization in the Kafka community?
`Thread.sleep()`
Generally, it is a poor practice:
1. It is impossible to find a good delay. The real delay depends on many
factors: hardware, OS, running processes, GC pause, etc.
2. The test is flaky - sometimes it passes, sometimes it fails
3. There is a temptation to increase the delay - this makes the test slow.
If many tests use this practice of Thread.sleep(), then all the tests take
considerably longer time. Nevertheless, sometimes this or that test fails.
Instead we can just check the properties of a `KafkaSink` after it has been
built with the `KafkaSinkBuilder`. This should be enough to test whether
`KafkaSinkBuilder` is implemented correctly.
--
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]