gemini-code-assist[bot] commented on code in PR #39174:
URL: https://github.com/apache/beam/pull/39174#discussion_r3500224692


##########
sdks/java/core/src/test/java/org/apache/beam/sdk/io/FileIOTest.java:
##########
@@ -291,23 +328,29 @@ public void testMatchWatchForNewFiles() throws 
IOException, InterruptedException
                 .filepattern(watchPath.resolve("*").toString())
                 .continuously(
                     Duration.millis(100),
-                    
Watch.Growth.afterTimeSinceNewOutput(Duration.standardSeconds(1))));
+                    Watch.Growth.eitherOf(
+                        new AfterNumberOfNewOutputs(numFiles),
+                        
Watch.Growth.afterTimeSinceNewOutput(Duration.standardSeconds(10)))));
     PCollection<MatchResult.Metadata> matchAllMetadata =
         p.apply("create for matchAll new files", 
Create.of(watchPath.resolve("*").toString()))
             .apply(
                 "match filename through matchAll",
                 FileIO.matchAll()
                     .continuously(
                         Duration.millis(100),
-                        
Watch.Growth.afterTimeSinceNewOutput(Duration.standardSeconds(1))));
+                        Watch.Growth.eitherOf(
+                            new AfterNumberOfNewOutputs(numFiles),
+                            
Watch.Growth.afterTimeSinceNewOutput(Duration.standardSeconds(10)))));
     PCollection<MatchResult.Metadata> matchUpdatedMetadata =
         p.apply(
             "match updated",
             FileIO.match()
                 .filepattern(watchPath.resolve("first").toString())
                 .continuously(
                     Duration.millis(100),
-                    
Watch.Growth.afterTimeSinceNewOutput(Duration.standardSeconds(1)),
+                    Watch.Growth.eitherOf(
+                        new AfterNumberOfNewOutputs(numFiles),

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using `numFiles` here is conceptually incorrect and fragile. `numFiles` 
represents the total number of unique files (3), whereas this matcher is 
specifically watching the file `"first"` which is updated 3 times. If 
`numFiles` is changed in the future, this matcher will wait for the wrong 
number of outputs and likely hit the 10-second timeout. Use a literal `3` (or a 
separate variable) to represent the number of updates for the `"first"` file.
   
   ```suggestion
                           new AfterNumberOfNewOutputs(3),
   ```



-- 
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]

Reply via email to