You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2023/11/10 15:52:00 UTC

[jira] [Comment Edited] (IO-821) 2.15.0 breaks backwards compatibility in PathUtils.fileContentEquals for the Zip file system

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

Gary D. Gregory edited comment on IO-821 at 11/10/23 3:51 PM:
--------------------------------------------------------------

Hello [~fhannes] 

Thank you for your report. This is fixed it git master and 2.15.1-SNAPSHOT build on the Apache Maven snapshot repository. 

Please verify.


was (Author: garydgregory):
Hello [~fhannes] 

Thank you for your report. This is fixed it git master and 2.15.1-SNAPSHOT build on the Apache Maven snapshot repository.

> 2.15.0 breaks backwards compatibility in PathUtils.fileContentEquals for the Zip file system
> --------------------------------------------------------------------------------------------
>
>                 Key: IO-821
>                 URL: https://issues.apache.org/jira/browse/IO-821
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.15.0
>            Reporter: Frédéric Hannes
>            Priority: Major
>             Fix For: 2.15.1
>
>
> h2. Relevant change
> Version {{2.15.0}} of commons-io features performance improvements by [~ggregory]  for PathUtils.fileContextEquals() as listed in the changelog:
> _Improve performance of PathUtils.fileContentEquals(Path, Path, LinkOption[], OpenOption[]) by about 60%, see PathUtilsContentEqualsBenchmark._
> The relevant change occurs in [commit {{dd93554b}}|https://github.com/apache/commons-io/commit/dd93554b692cabe884e7a097e431f475397a3b48#diff-4162512d2bb8d032482958d8dabacc1c2398e95597a49fa5b0fc02aabc8717d6R769], where the comparison of input streams through {{IOUtils.contentEquals()}} is replaced with {{{}RandomAccessFile.contentEquals(){}}}.
> h2. Issue description
> The issue occurs in {{{}RandomAccessFileMode.create(){}}}, where [{{Path.toFile()}}|https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toFile--] is called. This method like many in {{{}Path{}}}, can throw an {{UnsupportedOperationException}} if it is not implemented by the filesystem provider.
> In our particular case, we compare files from a zip archive with files on disk using the [zip filesystem provider that was introduced in Java 7|https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/zipfilesystemprovider.html]. The class {{jdk.nio.zipfs.ZipPath}} does not implement {{Path.toFile()}} and therefore throws an {{{}UnsupportedOperationException{}}}.
> Though it does not seem unreasonable to limit the functionality of this method to a specific subset of {{Path}} implementations, this does seem to be a substantial breaking change in behavior of an existing method, which I am not sure was intentional.
> As a workaround to resolve the issue without downgrading, we now call {{IOUtils.contentEquals()}} directly.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)