gemini-code-assist[bot] commented on code in PR #39272:
URL: https://github.com/apache/beam/pull/39272#discussion_r3557594608
##########
runners/flink/src/test/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/UnboundedSourceWrapperTest.java:
##########
@@ -665,15 +665,16 @@ private static void testSourceDoesNotShutdown(boolean
shouldHaveReaders) throws
// Wait to see if the wrapper shuts down immediately in case it
doesn't have readers
if (!shouldHaveReaders) {
// The expected state is for finalizeSource to sleep instead of
exiting
- while (true) {
- StackTraceElement[] callStack = thread.getStackTrace();
- if (callStack.length >= 2
- && "sleep".equals(callStack[0].getMethodName())
- && "finalizeSource".equals(callStack[1].getMethodName())) {
+ long deadlineMs = System.currentTimeMillis() + 9_000;
+ boolean reachedFinalizeSource = false;
+ while (System.currentTimeMillis() < deadlineMs) {
Review Comment:

Using `System.currentTimeMillis()` to measure elapsed time or timeouts is an
anti-pattern because it is sensitive to system clock adjustments (such as NTP
synchronization or manual clock changes). It is highly recommended to use
`System.nanoTime()` for monotonic time measurements instead.
```suggestion
long deadlineNs = System.nanoTime() + 9_000_000_000L;
boolean reachedFinalizeSource = false;
while (System.nanoTime() < deadlineNs) {
```
--
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]