[ 
https://issues.apache.org/jira/browse/MNG-5368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15847597#comment-15847597
 ] 

Hudson commented on MNG-5368:
-----------------------------

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


> UnsupportedOperationException thrown when version range is not correct in 
> dependencyManagement definitions
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-5368
>                 URL: https://issues.apache.org/jira/browse/MNG-5368
>             Project: Maven
>          Issue Type: Bug
>          Components: POM
>    Affects Versions: 3.0.4
>         Environment: MacOS 10.7.5 Darwin Kernel Version 11.4.2: 
> xnu-1699.32.7~1/RELEASE_X86_64 x86_64
>            Reporter: Andrew Haines
>            Assignee: Christian Schulte
>             Fix For: 3.5.0
>
>
> 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:
> {code}
> 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 );
> {code}
> 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:
> {code}
>    public Artifact createDependencyArtifact( Dependency d )
>     {
>         VersionRange versionRange;
>         try
>         {
>             versionRange = VersionRange.createFromVersionSpec( d.getVersion() 
> );
>         }
>         catch ( InvalidVersionSpecificationException e )
>         {
>             return null;
>         }
> {code}
> 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



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to