Skip to content

Commit

Permalink
MVERSIONS-159: Fixed IllegalStateException in corner cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
epabst committed Aug 4, 2011
1 parent e5ede52 commit 7671f03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,7 @@ public ExpressionEvaluator getExpressionEvaluator( MavenProject project )
getLog().debug( "Skipping property ${" + property.getName() + "}" );
i.remove();
}

if ( excludeProperties != null && excludeProperties.indexOf( property.getName() ) >= 0 )
else if ( excludeProperties != null && excludeProperties.indexOf( property.getName() ) >= 0 )
{
getLog().debug( "Ignoring property ${" + property.getName() + "}" );
i.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.maven.project.path.DefaultPathTranslator;
import org.apache.maven.settings.Settings;
Expand All @@ -35,9 +36,11 @@
import org.apache.maven.wagon.providers.file.FileWagon;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.execution.MavenSession;
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.ordering.VersionComparators;

import java.util.ArrayList;
import java.util.Map;

/**
* Test {@link DefaultVersionsHelper}
Expand Down Expand Up @@ -75,6 +78,22 @@ public void testRuleSets()
helper.getVersionComparator( "com.mycompany.maven", "old-maven-plugin" ) );
}

// This exposed the MVERSIONS-159 bug where the iterator.remove method was called twice since both
// the excludeProperties check and the includeProperties check triggered it.
public void testExcludedAndNotIncluded()
throws MojoExecutionException
{
VersionsHelper helper = createHelper();
MavenProject project = null;

Property[] propertyDefinitions = new Property[] {
new Property( "bar.version" )
};
// should not throw an IllegalStateException
Map result = helper.getVersionPropertiesMap( project, propertyDefinitions, "foo.version", "bar.version", false );
assertTrue( result.isEmpty() );
}


private VersionsHelper createHelper()
throws MojoExecutionException
Expand Down

0 comments on commit 7671f03

Please sign in to comment.