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

Gradle plugin creates fat jars that do not align with unspecified assumption that META-INF/MANIFEST.MF should be the first or second entry #16698

Closed
DanielThomas opened this issue May 1, 2019 · 0 comments
Labels
type: bug A general bug
Milestone

Comments

@DanielThomas
Copy link
Contributor

The boot jars produced by the Gradle plugin injects the launcher classes first, violating an implicit specification discussed here and in JarInputStream:

https://bugs.openjdk.java.net/browse/JDK-8031748

    public JarInputStream(InputStream in, boolean verify) throws IOException {
        super(in);
        this.doVerify = verify;

        // This implementation assumes the META-INF/MANIFEST.MF entry
        // should be either the first or the second entry (when preceded
        // by the dir META-INF/). It skips the META-INF/ and then
        // "consumes" the MANIFEST.MF to initialize the Manifest object.

In our case we're indexing jars from in a context where we don't have random access to the file, so that implicit contract makes it easy to know if we can expect a manifest or if we need to fallback, but it's not possible for these jars:

  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2019-02-15 10:26   org/
        0  2019-02-15 10:26   org/springframework/
        0  2019-02-15 10:26   org/springframework/boot/
        0  2019-02-15 10:26   org/springframework/boot/loader/
        0  2019-02-15 10:26   org/springframework/boot/loader/data/
        0  2019-02-15 10:26   org/springframework/boot/loader/jar/
        0  2019-02-15 10:26   org/springframework/boot/loader/archive/
        0  2019-02-15 10:26   org/springframework/boot/loader/util/
     2688  2019-02-15 10:26   org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
     5267  2019-02-15 10:26   org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
     3263  2019-02-15 10:26   org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class
     1487  2019-02-15 10:26   org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator$EntryComparator.class
     3837  2019-02-15 10:26   org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator.class
      282  2019-02-15 10:26   org/springframework/boot/loader/data/RandomAccessDataFile$1.class
     3116  2019-02-15 10:26   org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
    11548  2019-02-15 10:26   org/springframework/boot/loader/jar/Handler.class
     5243  2019-02-15 10:26   org/springframework/boot/loader/archive/ExplodedArchive.class
     4015  2019-02-15 10:26   org/springframework/boot/loader/data/RandomAccessDataFile.class
     4624  2019-02-15 10:26   org/springframework/boot/loader/jar/CentralDirectoryParser.class
     1813  2019-02-15 10:26   org/springframework/boot/loader/jar/ZipInflaterInputStream.class
      302  2019-02-15 10:26   org/springframework/boot/loader/archive/Archive$Entry.class
      273  2019-02-15 10:26   org/springframework/boot/loader/archive/ExplodedArchive$1.class
      485  2019-02-15 10:26   org/springframework/boot/loader/data/RandomAccessData.class
      437  2019-02-15 10:26   org/springframework/boot/loader/archive/Archive$EntryFilter.class
     7336  2019-02-15 10:26   org/springframework/boot/loader/archive/JarFileArchive.class
     1953  2019-02-15 10:26   org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
     1484  2019-02-15 10:26   org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
      266  2019-02-15 10:26   org/springframework/boot/loader/PropertiesLauncher$1.class
    19737  2019-02-15 10:26   org/springframework/boot/loader/PropertiesLauncher.class
     4684  2019-02-15 10:26   org/springframework/boot/loader/Launcher.class
     1502  2019-02-15 10:26   org/springframework/boot/loader/MainMethodRunner.class
     3608  2019-02-15 10:26   org/springframework/boot/loader/ExecutableArchiveLauncher.class
     1721  2019-02-15 10:26   org/springframework/boot/loader/WarLauncher.class
     1585  2019-02-15 10:26   org/springframework/boot/loader/JarLauncher.class
     5203  2019-02-15 10:26   org/springframework/boot/loader/util/SystemPropertyUtils.class
     1535  2019-02-15 10:26   org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class
     5699  2019-02-15 10:26   org/springframework/boot/loader/LaunchedURLClassLoader.class
      616  2019-02-15 10:26   org/springframework/boot/loader/jar/Bytes.class
      702  2019-02-15 10:26   org/springframework/boot/loader/jar/JarURLConnection$1.class
     1779  2019-02-15 10:26   org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
     4306  2019-02-15 10:26   org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
     1081  2019-02-15 10:26   org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
     9854  2019-02-15 10:26   org/springframework/boot/loader/jar/JarURLConnection.class
      945  2019-02-15 10:26   org/springframework/boot/loader/archive/Archive.class
     1233  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFile$2.class
     2062  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFile$1.class
     1374  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFile$JarFileType.class
    15076  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFile.class
     4976  2019-02-15 10:26   org/springframework/boot/loader/jar/AsciiBytes.class
     1593  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFileEntries$1.class
     2046  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
      540  2019-02-15 10:26   org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
      299  2019-02-15 10:26   org/springframework/boot/loader/jar/JarEntryFilter.class
     3619  2019-02-15 10:26   org/springframework/boot/loader/jar/JarEntry.class
      345  2019-02-15 10:26   org/springframework/boot/loader/jar/FileHeader.class
     3650  2019-02-15 10:26   org/springframework/boot/loader/jar/StringSequence.class
    14087  2019-02-15 10:26   org/springframework/boot/loader/jar/JarFileEntries.class
     1102  2019-02-15 10:26   org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
        0  2019-04-30 01:41   META-INF/
      858  2019-04-30 01:41   META-INF/MANIFEST.MF

In the meantime we're going to have our code check for this case specifically.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 1, 2019
@wilkinsona wilkinsona changed the title Spring Boot launcher jars invalid for some cases Gradle plugin creates fat jars that do not align with assumption that META-INF/MANIFEST.MF should be the first or second entry May 2, 2019
@wilkinsona wilkinsona changed the title Gradle plugin creates fat jars that do not align with assumption that META-INF/MANIFEST.MF should be the first or second entry Gradle plugin creates fat jars that do not align with unspecified assumption that META-INF/MANIFEST.MF should be the first or second entry May 2, 2019
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 2, 2019
@wilkinsona wilkinsona added this to the 2.1.x milestone May 2, 2019
@wilkinsona wilkinsona self-assigned this May 2, 2019
@philwebb philwebb modified the milestones: 2.1.x, 2.1.6 Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants