Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6641

NPE from AttachedArtifact.getVersion rather than meaningful error

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6.0
    • Fix Version/s: waiting-for-feedback
    • Component/s: Errors
    • Labels:
      None
    • Environment:
      any

      Description

      This issue is basically re-reporting issue https://issues.apache.org/jira/browse/MNG-4731, which was closed in theĀ great Jira clean up of 2014. 5 years later I can report it is still an issue.

      The issue occurs when the information passed to AttachedArtifact violates any of the validations in DefaultArtifact.validateIdentity(). The call to getVersion() will throw an NPE because it is overridable in the DefaultArtifact and parent has not been initialized yet in AttachedArtifact. MNG-4731 explains this more clearly.

      A comment on that ticket suggests that the problem is that AttachedArtifact was called directly instead of using MavenProjectHelper.attachArtifact(). That is not true as can be seen from my stack trace:

      Caused by: java.lang.NullPointerException
          at org.apache.maven.project.artifact.AttachedArtifact.getVersion (AttachedArtifact.java:138)
          at org.apache.maven.artifact.DefaultArtifact.validateIdentity (DefaultArtifact.java:149)
          at org.apache.maven.artifact.DefaultArtifact.<init> (DefaultArtifact.java:124)
          at org.apache.maven.project.artifact.AttachedArtifact.<init> (AttachedArtifact.java:49)
          at org.apache.maven.project.DefaultMavenProjectHelper.attachArtifact (DefaultMavenProjectHelper.java:63)
          at org.apache.maven.plugins.source.AbstractSourceJarMojo.packageSources (AbstractSourceJarMojo.java:324)
          at org.apache.maven.plugins.source.AbstractSourceJarMojo.packageSources (AbstractSourceJarMojo.java:253)
          at org.apache.maven.plugins.source.AbstractSourceJarMojo.execute (AbstractSourceJarMojo.java:216)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dalewking Dale King
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: