Skip to content

Commit beab530

Browse files
authored
[MRESOLVER-653] NPE in case of failed result (#640)
Obvious typo: result artifact may be null, it is request artifact that wanted to be checked. Added UT as well. --- https://issues.apache.org/jira/browse/MRESOLVER-653
1 parent 859a08e commit beab530

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/resolution/TrustedChecksumsArtifactResolverPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ final boolean record = ConfigUtils.getBoolean(session, false, CONFIG_PROP_RECORD
162162
final boolean snapshots = ConfigUtils.getBoolean(session, false, CONFIG_PROP_SNAPSHOTS);
163163

164164
for (ArtifactResult artifactResult : artifactResults) {
165-
if (artifactResult.getArtifact().isSnapshot() && !snapshots) {
165+
if (artifactResult.getRequest().getArtifact().isSnapshot() && !snapshots) {
166166
continue;
167167
}
168168
if (artifactResult.isResolved()) {

maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/resolution/TrustedChecksumsArtifactResolverPostProcessorTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ void haveMatchingChecksumPass() {
149149
assertTrue(artifactResult.isResolved());
150150
}
151151

152+
@Test
153+
void unresolvedArtifact() {
154+
ArtifactResult artifactResult =
155+
createArtifactResult(artifactWithTrustedChecksum).setArtifact(null);
156+
assertFalse(artifactResult.isResolved());
157+
158+
subject.postProcess(session, Collections.singletonList(artifactResult)); // no NPE
159+
}
160+
152161
@Test
153162
void haveNoChecksumPass() {
154163
ArtifactResult artifactResult = createArtifactResult(artifactWithoutTrustedChecksum);

0 commit comments

Comments
 (0)