Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Apache Commons Compress to 1.15 #71

Closed
plamentotev opened this issue Oct 17, 2017 · 6 comments
Closed

Upgrade Apache Commons Compress to 1.15 #71

plamentotev opened this issue Oct 17, 2017 · 6 comments
Assignees
Milestone

Comments

@plamentotev
Copy link
Member

plamentotev commented Oct 17, 2017

It brings some fixes and most importantly should fix #57

@plamentotev plamentotev added this to the 3.6 milestone Oct 17, 2017
@plamentotev plamentotev self-assigned this Oct 17, 2017
@plamentotev plamentotev removed this from the 3.6 milestone Oct 18, 2017
@plamentotev
Copy link
Member Author

plamentotev commented Oct 18, 2017

After the upgrade there is a test failing so I'll postpone the upgrade until the issue is found and resolved. I'll debug it to see where the problem is.

@michael-o
Copy link
Member

Are you having the same null character issue? Compress 1.15 seems to be broken for me.

@plamentotev
Copy link
Member Author

plamentotev commented Oct 19, 2017

I think we have the same issue in mind. ZipArchiverTest#testSymlinkArchivedFileSet fails because the symlinks in the resulting archive does have several null characters at the end. Do you encounter the same issue?

I found the root cause. In AbstractZipArchiver#zipFile there is the following code:

            if ( ze.isUnixSymlink() )
            {
                ZipEncoding enc = ZipEncodingHelper.getZipEncoding( getEncoding() );
                final byte[] bytes = enc.encode( symlinkDestination ).array();
                payload = new ByteArrayInputStream( bytes );
                zOut.addArchiveEntry( ze, createInputStreamSupplier( payload ), true );
            }

The offender is enc.encode( symlinkDestination ).array();. Accordion to the ZipEncoding#encode Javadocs the returned "...byte buffer is positioned at the beginning of the encoded result, the byte buffer has a backing array and the limit of the byte buffer points to the end of the encoded result." We take the whole backing array. We should take its content up to the limit instead. Commons Compress 1.15 returns different ZipEncoding implementation(compared to 1.14) when ZipEncodingHelper.getZipEncoding( getEncoding() ) is called and that is why the bug manifests with the upgrade.

I'll submit a fix tomorrow after I double check that we don't have the same bug somewhere else in the code.

@michael-o
Copy link
Member

Correct, I see several null chars in the debugger.

@michael-o
Copy link
Member

@plamentotev Are you talking about Buffer#limit()?

@plamentotev plamentotev added this to the 3.6 milestone Oct 21, 2017
@plamentotev
Copy link
Member Author

Yes. I've made a merge request with the fix and the upgrade - #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants