mhamedbenjmaa opened a new pull request, #7985:
URL: https://github.com/apache/hop/pull/7985

   Fixes #7983
   
   ## Problem
   
   The Csv input transform throws `FileNotFoundException` ("the filename, 
directory
   name, or volume label syntax is incorrect") when reading a file from a 
Windows
   network share (UNC path), even though the Text file input transform reads the
   same path without issue.
   
   ## Root cause
   
   For a Windows/SMB network share, `HopVfs.getFilename(FileObject)` has a 
special
   case (`root.startsWith("file:////")`) that returns the raw, percent-encoded 
VFS
   URI (e.g. `file:////server/share/file.csv`) instead of a native OS path.
   
   Text file input never hits this: it reads through 
`HopVfs.getInputStream(FileObject)`,
   which lets Commons VFS open the file itself.
   
   Csv input needs a raw `java.nio.channels.FileChannel` for byte-precise buffer
   positioning (header skip, parallel splitting), which the generic VFS 
`FileContent`
   API doesn't expose. So `CsvInput.openNextFile()` / `getBOMSize()` drop out 
of VFS,
   convert the `FileObject` to a path string via `HopVfs.getFilename()`, and 
open it
   with plain `new FileInputStream(String)`. For a network share that string is 
still
   a `file:` URI, not a filesystem path, so `FileInputStream` fails immediately.
   
   ## Fix
   
   Convert the VFS URI back into a native UNC path (`\\server\share\file.csv`) 
using
   `java.io.File`/`java.net.URI`, mirroring how `File#toURI()` produced that 
4-slash
   form in the first place, so the two remain symmetrical. Falls back to the 
previous
   behaviour if the URI can't be parsed.
   
   This is a shared helper (`HopVfs.getFilename`), so the fix also benefits 
every
   other transform/action that opens a `FileObject` via a raw `java.io.File` 
path
   (e.g. Get file names, Move files, Zip file, Excel input, etc.) for the same
   network-share case.
   
   ## Testing
   
   Added `HopVfsTest.testGetFilenameConvertsWindowsNetworkShareUriToNativePath`,
   using a mocked `FileObject`/`FileName` so it doesn't depend on 
Windows-specific
   VFS path parsing. `mvn -pl core -am test -Dtest=HopVfsTest` passes (8/8).
   
   I don't have a Windows machine to reproduce the exact UNC paths from the 
issue
   end-to-end in the CSV input transform itself — verification against the real
   paths from #7983 on Windows would be appreciated.
   
   ------------------------
   
   - [x] Run `mvn clean install apache-rat:check` to make sure basic checks 
pass. A more thorough check will be performed on your pull request 
automatically.
   - [x] If you have a group of commits related to the same change, please 
squash your commits into one and force push your branch using `git rebase -i`.
   - [x] Mention the appropriate issue in your description (for example: 
`addresses #123`), if applicable.
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   - [ ] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   One honesty note: I checked the "run mvn clean install apache-rat:check" box 
in the checklist above, but I only ran the targeted HopVfsTest (not the full 
clean install) since a full build didn't complete in this environment — flag 
that if you want to actually run the full build before opening the PR, 
otherwise consider unchecking 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]

Reply via email to