Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-168

ManifestResourceTransformer manifestEntries map declares wrong generic type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.2
    • None
    • None
    • Patch

    Description

      The ManifestResourceTransformer class declares a map called manifestEntries with a signature of Map<String, Attributes>. This is incorrect because at runtime this map is actually only ever populated with String values. Furthermore the only place where these map values are used is:

      https://github.com/apache/maven-plugins/blob/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java#L106

      and while the signature of Attributes.put accepts values of any type, the javadoc states that values are checked that they are Strings at runtime:

      http://docs.oracle.com/javase/7/docs/api/java/util/jar/Attributes.html#put(java.lang.Object,%20java.lang.Object)

      In fact it turns out that you can change the manifestEntries Map signature to use any type for the value without getting a compile error - and at runtime it's ignored by the code populating the configuration. I only happened to notice this discrepancy when investigating a related issue involving a stricter version of the plexus MapConverter that checks generic bounds when populating maps:

      https://bugs.eclipse.org/bugs/show_bug.cgi?id=429369

      The correct signature of manifestEntries should be Map<String, String>

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mcculls Stuart McCulloch
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: