agjendem opened a new pull request, #1815:
URL: https://github.com/apache/maven-mvnd/pull/1815

   ## Description
   
   Fixes #1438 on 1.x. #1262 is the same failure on master.
   
   `MvndNativeLoader.contentsEquals` compares whole 8 KiB buffers with 
`Arrays.equals`. When the last block is shorter, it also compares the bytes 
after it, which are left over from the previous block. Those are only equal if 
neither stream changed them.
   
   On Fedora 40 and later the system zlib is zlib-ng. With a JDK that links it, 
for example Corretto, reading the jar entry changes the buffer right after the 
returned count. A byte-identical file is then reported as "Content differs", 
`CLibrary` fails to initialize, and `mvnd -v` prints 
`java.lang.ExceptionInInitializerError`.
   
   This compares only the bytes that were read. jansi had the same comparison 
and made the same fix in fusesource/jansi#318. master has the same comparison 
and needs the same fix.
   
   ## Verification
   
   - `./mvnw -pl native test -Dtest=MvndNativeLoaderTest`: 
`contentsEqualsIgnoresBytesPastWhatWasRead` fails without the fix (`expected: 
<null> but was: <Content differs>`), and all 3 tests pass with it.
   - Fedora 44, Corretto 25.0.4: loading `CLibrary` from the `mvnd-native` jar 
built from `mvnd-1.x` fails with `Failed to write a native library file … 
because Content differs`. The jar built with this change loads it.
   
   ## AI assistance
   
   I used generative AI assistance while working on this contribution. I 
reviewed and verified the resulting changes and remain responsible for the 
contribution.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


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