Eliminated duplicate jar entries caused by consecutive slashes.

Review Request #2763 - Created Sept. 3, 2015 and submitted

Information
Garrett Malmquist
pants
gmalmquist/fix-jar-tool-dups
2131
1d04f26...
Reviewers
pants-reviews
jsirois, stuhood, zundel

We noticed this duplication in some of our internal jar builds. It
mostly doesn't cause any problems, but was breaking jarjar when it
tried to shade them (for rb 2754).

Despite only having one version of the class most of the way
through the jar building pipeline, duplicate classes were
artificially created due to a bug in the path calculation for the
jar entry.

Specifically, we create the final jar entry path by calling 'join'
on the path separator ('/') over an iterable of path components,
however it appears there are some cases where the path components
may contain trailing slashes.

Internally, this resulted in .jar files with entries that looked
like:

com/squareup/foo/bar/app/package/File.class
com//squareup/foo/bar/app/package/File.class
com/squareup//foo/bar/app/package/File.class
com/squareup/foo//bar/app/package/File.class
com/squareup/foo/bar//app/package/File.class
com/squareup/foo/bar/app//package/File.class
com/squareup/foo/bar/app/package//File.class

This is a very simple (but subtle) bug, and the fix is similarly
simple.

CI went green: https://travis-ci.org/pantsbuild/pants/builds/78817173

John Sirois
Garrett Malmquist
Eric Ayers
John Sirois
Garrett Malmquist
John Sirois
Garrett Malmquist
Garrett Malmquist
Review request changed

Status: Closed (submitted)

Change Summary:

In: a4d5c5e39a0e5fb203dd2f8c815a50fae1d49361

Eric Ayers

this change was published as jar-tool version 0.0.7. See https://rbcommons.com/s/twitter/r/2779/

Loading...