You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andrzej Jarmoniuk (Jira)" <ji...@apache.org> on 2022/09/08 04:26:00 UTC
[jira] [Comment Edited] (MSHARED-1130) PatternIncludesArtifactFilters raising NPE for patterns w/ wildcards and artifactoid w/ null on any coordinate
[ https://issues.apache.org/jira/browse/MSHARED-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17601626#comment-17601626 ]
Andrzej Jarmoniuk edited comment on MSHARED-1130 at 9/8/22 4:25 AM:
--------------------------------------------------------------------
Simple unit test to reproduce:
{code:java:title=AbstractPatternArtifactFilterTest}
@Test
public void testPartialWildcardShouldNotMatchEmptyComponent()
{
final String groupId = "com.mycompany.myproject";
final String artifactId = "some-artifact-id";
final String version = "1.0.0";
Artifact artifact = mock( Artifact.class );
when( artifact.getGroupId() ).thenReturn( groupId );
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getVersion() ).thenReturn( version );
when( artifact.getType() ).thenReturn( null );
when( artifact.getBaseVersion() ).thenReturn( "version" );
final List<String> patterns = new ArrayList<>();
patterns.add( "com.mycompany.myproject:some-artifact-id:*:ERROR*" );
final ArtifactFilter filter = createFilter( patterns );
if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
else
{
assertFalse( filter.include( artifact ) );
}
{code}
was (Author: ajarmoniuk):
Simple unit test to reproduce:
{code:java:title=AbstractPatternArtifactFilterTest}
@Test
public void testPartialWildcardShouldNotMatchEmptyComponent()
{
final String groupId = "com.mycompany.myproject";
final String artifactId = "some-artifact-id";
final String version = "1.0.0";
Artifact artifact = mock( Artifact.class );
when( artifact.getGroupId() ).thenReturn( groupId );
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getVersion() ).thenReturn( version );
when( artifact.getType() ).thenReturn( null );
when( artifact.getBaseVersion() ).thenReturn( "version" );
final List<String> patterns = new ArrayList<>();
patterns.add( "com.mycompany.myproject:some-artifact-id:*:ERROR*" );
final ArtifactFilter filter = createFilter( patterns );
if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
else
{
assertTrue( filter.include( artifact ) );
}
{code}
> PatternIncludesArtifactFilters raising NPE for patterns w/ wildcards and artifactoid w/ null on any coordinate
> --------------------------------------------------------------------------------------------------------------
>
> Key: MSHARED-1130
> URL: https://issues.apache.org/jira/browse/MSHARED-1130
> Project: Maven Shared Components
> Issue Type: Bug
> Affects Versions: maven-common-artifact-filters-3.3.1
> Reporter: Andrzej Jarmoniuk
> Priority: Major
>
> Encountered an NPE from {{PatternIncludesArtifactFilters.match}} if the pattern includes wildcards and the artifactoid returns null on any of its coordinates.
> In such cases, the {{value}} argument will be null, which will lead to an NPE when it's being dereferenced in line 653.
> This led to https://github.com/mojohaus/versions-maven-plugin/issues/673
> In this case, {{token}} was {{JET*-SNAPSHOT}} and {{value}} as returned from the artifactoid was null.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)