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

UnsupportedOperationException thrown when version range is not correct in dependencyManagement definitions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.4
    • Fix Version/s: 3.5.0-alpha-1, 3.5.0
    • Component/s: POM
    • Labels:
      None
    • Environment:
      MacOS 10.7.5 Darwin Kernel Version 11.4.2: xnu-1699.32.7~1/RELEASE_X86_64 x86_64

      Description

      When specifying a non valid version range in a dependencyManagement tag, instead of a descriptive error message we get a UnsupportedOperationException thrown. The code at fault in org.apache.maven.project.MavenProject#getManagedVersionMap is:

      map = new HashMap<String, Artifact>();
                      for ( Iterator<Dependency> i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
                      {
                          Dependency d = i.next();
      
                          Artifact artifact = repositorySystem.createDependencyArtifact( d );
      
                          if ( artifact == null )
                          {
                              map = Collections.emptyMap();
                          }
      
                          map.put( d.getManagementKey(), artifact );
      

      When the artifact is null, the map is set to an immutable map and then the null artifact is then attempted to be put into it. This will always fail. This particular problem originates from code further down the stack in org.apache.maven.repository.legacy.LegacyRepositorySystem:

         public Artifact createDependencyArtifact( Dependency d )
          {
              VersionRange versionRange;
              try
              {
                  versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
              }
              catch ( InvalidVersionSpecificationException e )
              {
                  return null;
              }
      
      

      Instead of signalling appropriately that an error has occurred, this exception is consumed and thus causes the erroneous behaviour mentioned in the first code snippet

        Issue Links

          Activity

          Show
          jvanzyl Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014
          Hide
          jvanzyl Jason van Zyl added a comment -

          Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

          Show
          jvanzyl Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.
          Hide
          selliott@paml.com Shaun added a comment -

          This should be reopened. At the very least, it would be ideal to get a an error log message indicating there is a version range problem.

          Show
          selliott@paml.com Shaun added a comment - This should be reopened. At the very least, it would be ideal to get a an error log message indicating there is a version range problem.
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in maven-3.x #1179 (See https://builds.apache.org/job/maven-3.x/1179/)
          MNG-5368 UnsupportedOperationException thrown when version range is (schulte: rev f2a8a4580f417a59afe34e425df150740429a5ea)

          • maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in maven-3.x #1179 (See https://builds.apache.org/job/maven-3.x/1179/ ) MNG-5368 UnsupportedOperationException thrown when version range is (schulte: rev f2a8a4580f417a59afe34e425df150740429a5ea) maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
          Hide
          stephenc Stephen Connolly added a comment -

          Maven 3.4.0 has been dropped. See this thread for more details.

          This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

          Show
          stephenc Stephen Connolly added a comment - Maven 3.4.0 has been dropped. See this thread for more details. This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1534 (See https://builds.apache.org/job/maven-3.x/1534/)
          MNG-5368 UnsupportedOperationException thrown when version range is (schulte: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=a3cdfbbbe9dcbd2737e3b4c1836c402f5d83ed46)

          • (edit) maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1534 (See https://builds.apache.org/job/maven-3.x/1534/ ) MNG-5368 UnsupportedOperationException thrown when version range is (schulte: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=a3cdfbbbe9dcbd2737e3b4c1836c402f5d83ed46 ) (edit) maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java

            People

            • Assignee:
              schulte77 Christian Schulte
              Reporter:
              ajh21 Andrew Haines
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development