Maven Release Plugin
  1. Maven Release Plugin
  2. MRELEASE-318

Release plugin throws NullPointerException when using version range for dependency

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta-7
    • Fix Version/s: 2.1
    • Component/s: prepare
    • Labels:
      None
    • Flags:
      Patch

      Description

      After upgrading to 2.0.8 I find that the release plugin throws NPE if any dependency uses version range.

      I have one dependency with version range <version>[1.0,2.0)</version> the rest are test scope with fixed version.

      Here is the crash stack trace:
      java.lang.NullPointerException: version was null for com.xrite:xrite-colorlib-api
      [13:42:05]: at org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifact.java:362)
      [13:42:05]: at org.apache.maven.artifact.DefaultArtifact.isSnapshot(DefaultArtifact.java:557)
      [13:42:05]: at org.apache.maven.shared.release.phase.CheckDependencySnapshotsPhase.checkArtifact(CheckDependencySnapshotsPhase.java:252)
      [13:42:05]: at org.apache.maven.shared.release.phase.CheckDependencySnapshotsPhase.checkProject(CheckDependencySnapshotsPhase.java:138)
      [13:42:05]: at org.apache.maven.shared.release.phase.CheckDependencySnapshotsPhase.execute(CheckDependencySnapshotsPhase.java:106)
      [13:42:05]: at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:194)
      [13:42:05]: at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:131)
      [13:42:05]: at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:94)
      [13:42:05]: at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:127)
      [13:42:05]: at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
      [13:42:05]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
      [13:42:05]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:513)
      [13:42:05]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:483)
      [13:42:05]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
      [13:42:05]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:228)
      [13:42:05]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
      [13:42:05]: at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
      [13:42:05]: at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
      [13:42:05]: at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
      [13:42:05]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [13:42:05]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [13:42:05]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [13:42:05]: at java.lang.reflect.Method.invoke(Method.java:597)
      [13:42:05]: at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      [13:42:05]: at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      [13:42:05]: at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      [13:42:05]: at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

      It seems the reason version is null is that the call to selectVersionFromNewRangeIfAvailable() assumes that versionRange.getRecommendedVersion() will always return non-null, else it sets the version to null! However during the release:prepare phase this is not true, see the output:

      [13:42:04]: [INFO] [release:prepare]
      [13:42:04]: [INFO] Verifying that there are no local modifications...
      [13:42:04]: [INFO] Executing: svn --non-interactive status
      [13:42:04]: [INFO] Working directory: C:\BuildAgent\work\23044d751bcc9843
      [13:42:05]: [INFO] Checking dependencies and plugins for snapshots ...
      [13:42:05]: TEST!!! version=null
      [13:42:05]: TEST!!! versionRange=[1.0,2.0)
      [13:42:05]: TEST!!! getRecommendedVersion=null

      TEST!!! Lines are my test code so I could see what is going on here.

      1. MNG-3351_dependency_poms.zip
        17 kB
        Dave Hoffer
      2. MNG-3351.zip
        7 kB
        Dave Hoffer
      3. MNG-3351-unittest.patch
        13 kB
        Mark Hobson
      4. simple-testcase.zip
        2 kB
        Mark Hobson
      5. simple-test-case-console-log.txt
        5 kB
        Dave Hoffer

        Issue Links

          Activity

          David Hoffer created issue -
          Brian Fox made changes -
          Field Original Value New Value
          Link This issue is duplicated by MDEP-134 [ MDEP-134 ]
          Brian Fox made changes -
          Affects Version/s 2.0.8 [ 13139 ]
          Affects Version/s 2.0.9 [ 13801 ]
          Dave Hoffer made changes -
          Attachment MNG-3351.zip [ 32040 ]
          Dave Hoffer made changes -
          Attachment MNG-3351_dependency_poms.zip [ 32052 ]
          Mark Hobson made changes -
          Attachment simple-testcase.zip [ 32067 ]
          Dave Hoffer made changes -
          Attachment simple-test-case-console-log.txt [ 32073 ]
          Mark Hobson made changes -
          Affects Version/s 2.0.9 [ 13801 ]
          Key MNG-3351 MRELEASE-318
          Project Maven 2 [ 10500 ] Maven 2.x Release Plugin [ 11144 ]
          Affects Version/s 2.0-beta-7 [ 13560 ]
          Mark Hobson made changes -
          Attachment MNG-3351-unittest.patch [ 32221 ]
          Mark Hobson made changes -
          Link This issue is duplicated by MNG-3372 [ MNG-3372 ]
          Benjamin Bentmann made changes -
          Link This issue depends upon MNG-3092 [ MNG-3092 ]
          Arnaud HERITIER made changes -
          Component/s prepare [ 13615 ]
          Arnaud HERITIER made changes -
          Patch Submitted [Yes]
          Testcase included yes
          Carlo de Wolf made changes -
          Link This issue is duplicated by MRELEASE-414 [ MRELEASE-414 ]
          Stephen Cooper made changes -
          Link This issue is duplicated by MRELEASE-519 [ MRELEASE-519 ]
          Brett Porter made changes -
          Fix Version/s 2.1 [ 12571 ]
          Brett Porter made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Assignee Brett Porter [ brettporter ]
          Brett Porter made changes -
          Link This issue is duplicated by MRELEASE-574 [ MRELEASE-574 ]
          Brett Porter made changes -
          Link This issue is related to MRELEASE-510 [ MRELEASE-510 ]
          bugittaa made changes -
          Link This issue relates to MRELEASE-620 [ MRELEASE-620 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 12:15:05 UTC 2015 [ 1428236105845 ]
          Mark Thomas made changes -
          Workflow jira [ 12724135 ] Default workflow, editable Closed status [ 12763341 ]
          Mark Thomas made changes -
          Patch Submitted Yes [ 10763 ]
          Flags Patch [ 10430 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 00:52:26 UTC 2015 [ 1428281546237 ]
          Mark Thomas made changes -
          Workflow jira [ 12962384 ] Default workflow, editable Closed status [ 13000440 ]

            People

            • Assignee:
              Brett Porter
              Reporter:
              David Hoffer
            • Votes:
              17 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development