yquaziii commented on code in PR #40109:
URL: https://github.com/apache/beam/pull/40109#discussion_r4064506064


##########
sdks/java/core/src/test/java/org/apache/beam/sdk/io/FileSystemsTest.java:
##########
@@ -63,6 +63,38 @@ public class FileSystemsTest {
   @Rule public ExpectedException thrown = ExpectedException.none();
   private LocalFileSystem localFileSystem = new LocalFileSystem();
 
+  @Test
+  public void testMatchSingleFileSpecExceptionChaining() throws Exception {
+    java.io.IOException rootCause = new java.io.IOException("403 Forbidden: 
Fake GCS Error");
+    MatchResult failedResult = MatchResult.create(MatchResult.Status.ERROR, 
rootCause);
+
+    FileSystem mockFileSystem = mock(FileSystem.class);

Review Comment:
   Thank you for taking a look, 
   
   [1] Setting up LocalFileSystem with invalid permissions:
   
   > I was checking 
[LocalFileSystem.java](https://github.com/apache/beam/blob/7143520f90d93516a7b1ea948d2c406f6dee01fd/sdks/java/core/src/main/java/org/apache/beam/sdk/io/LocalFileSystem.java#L269)
 and I think it won't trigger the code path we are trying to fix. 
LocalFileSystem.match() never wraps exceptions in a MatchResult with 
Status.ERROR.  When it fails, it either propagates an IOException directly or 
returns Status.NOT_FOUND (bypassing the matchResult.status() != Status.OK block 
entirely)
   
   The bug specifically affects filesystems like GcsFileSystem which catch 
inner exceptions and return them as Status.ERROR.
   
   [2] Using an in-memory fake for a blobstore:  
   
   > I checked to see if we had an existing in-memory fake, but a search for 
classes extending FileSystem in 
[sdks/java/core/src/test](sdks/java/core/src/test)  shows we don't currently 
have any test blobstore implementations available in the core module. Please 
let me know if you have any suggestion for it. 
   
   would you prefer I replace the mock with a small, private inner class (e.g., 
FakeErrorFileSystem extends FileSystem) directly inside FileSystemsTest.java? 
It could hardcode the Status.ERROR return to simulate the failure without 
relying on Mockito ? 



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