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

Slawomir Jaranowski commented on MSHARED-1130:
----------------------------------------------

Interesting case, but in {{DefaultArtifact}} we have:

{code}
public DefaultArtifact( String groupId, String artifactId, VersionRange 
versionRange, String scope, String type,
                            String classifier, ArtifactHandler artifactHandler, 
boolean optional )
    {
        this.groupId = groupId;

        this.artifactId = artifactId;

        this.versionRange = versionRange;

        selectVersionFromNewRangeIfAvailable();

        this.artifactHandler = artifactHandler;

        this.scope = scope;

        this.type = type;

        if ( classifier == null )
        {
            classifier = artifactHandler.getClassifier();
        }

        this.classifier = classifier;

        this.optional = optional;

        validateIdentity();
    }
{code}

and

{code}
    private void validateIdentity()
    {
        if ( empty( groupId ) )
        {
            throw new InvalidArtifactRTException( groupId, artifactId, 
getVersion(), type,
                "The groupId cannot be empty." );
        }

        if ( artifactId == null )
        {
            throw new InvalidArtifactRTException( groupId, artifactId, 
getVersion(), type,
                "The artifactId cannot be empty." );
        }

        if ( type == null )
        {
            throw new InvalidArtifactRTException( groupId, artifactId, 
getVersion(), type,
                "The type cannot be empty." );
        }

        if ( ( version == null ) && ( versionRange == null ) )
        {
            throw new InvalidArtifactRTException( groupId, artifactId, 
getVersion(), type,
                "The version cannot be empty." );
        }
    }
{code}

so {{type}} can not be {{null}}

> 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
>          Components: maven-common-artifact-filters
>    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)

Reply via email to