Skip to content

[MRESOLVER-597] RepositorySystem.resolveArtifactRepositorySystemSession session, ArtifactRequest request) throws unexpected IllegalArgumentException #1269

@jira-importer

Description

@jira-importer

Konrad Windszus opened MRESOLVER-597 and commented

I see the following exception when trying to resolve an artifact which does not have a version via

ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
ArtifactResult result = repositorySystem.resolveArtifact(repositorySession, request);
java.lang.IllegalArgumentException: version can neither be null, empty nor blank
    at org.apache.maven.artifact.ArtifactUtils.notBlank (ArtifactUtils.java:95)
    at org.apache.maven.artifact.ArtifactUtils.key (ArtifactUtils.java:86)
    at org.apache.maven.ReactorReader.findArtifact (ReactorReader.java:96)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:350)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:261)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:243)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact (DefaultRepositorySystem.java:278)

According to

public DefaultArtifact(String groupId, String artifactId, String extension, String version) {
every argument passed to the constructor of DefaultArtifact may be null or empty. However not all Artifact objects are valid then for ArtifactRequest.

Although throwing an exception is totally valid here either the IllegalArgumentException should be documented in the javadoc of https://maven.apache.org/resolver/apidocs/org/eclipse/aether/RepositorySystem.html#resolveArtifact(org.eclipse.aether.RepositorySystemSession,org.eclipse.aether.resolution.ArtifactRequest).
IMHO it would make sense to throw the exception already when either populating or constructing the ArtifactRequest, as only non empty coordinates are supported.


Affects: 1.9.20

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions