[ 
https://issues.apache.org/jira/browse/HADOOP-20065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18138462#comment-18138462
 ] 

ASF GitHub Bot commented on HADOOP-20065:
-----------------------------------------

LuciferYang opened a new pull request, #8929:
URL: https://github.com/apache/hadoop/pull/8929

   ### Description of PR
   
   JIRA: https://issues.apache.org/jira/browse/HADOOP-20065
   
   `HarFileSystem` is read-only, but its `createFile(Path)` and 
`appendFile(Path)` return `fs.createFile(path)` and `fs.appendFile(path)`, 
builders of the underlying file system, so `build()` writes there. For a path 
without a scheme, which HAR treats as inside the archive, `harFs.createFile(new 
Path("/user/foo/a.har/x")).build()` creates or truncates that file on the 
underlying file system, and `appendFile` appends to it. A `har://` path fails 
with an unchecked `Wrong FS` exception.
   
   The overrides came from `FilterFileSystem` in HDFS-11170. This patch removes 
them, so the `FileSystem` defaults build through `HarFileSystem` and fail with 
an `IOException`, and adds both methods to `MustNotImplement` in 
`TestHarFileSystem`. HADOOP-16107 fixed the same problem in 
`ChecksumFileSystem`.
   
   ### How was this patch tested?
   
   Added 
`TestHarFileSystemBasics#testNegativeHarFsCreateFileAndAppendFileBuilders`: 
`createFile(p).build()`, `createFile(p).recursive().build()` and 
`appendFile(p).build()` on a path that exists on the underlying file system all 
throw `IOException`, and the underlying file keeps its length. Without the fix 
the first call succeeds and truncates the file.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: Have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   - [x] The PR includes the phrase "Contains content generated by Claude Opus".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Opus.
   




> HarFileSystem#createFile and #appendFile return builders of the underlying 
> file system and bypass its read-only checks
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-20065
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20065
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>            Reporter: Yang Jie
>            Priority: Minor
>
> HarFileSystem is read-only: create(), append() and the other write operations 
> throw "Har: ... not allowed". createFile(Path) and appendFile(Path), however, 
> return {{fs.createFile(path)}} and {{fs.appendFile(path)}}, builders of the 
> underlying file system, so build() writes there. For a path without a scheme, 
> which HAR treats as a path inside the archive, {{harFs.createFile(new 
> Path("/user/foo/a.har/x")).build()}} creates or truncates /user/foo/a.har/x 
> on the underlying file system, and appendFile appends to an existing file 
> there. A har:// path fails with an unchecked "Wrong FS" 
> IllegalArgumentException instead of an IOException.
> The two overrides were copied from FilterFileSystem in HDFS-11170. The fix 
> removes them, so the FileSystem defaults build through HarFileSystem and fail 
> with an IOException, and adds both methods to MustNotImplement in 
> TestHarFileSystem. HADOOP-16107 fixed the same problem in ChecksumFileSystem.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to