diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java index 30c3e8ad0..1b76940e2 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java @@ -142,6 +142,7 @@ public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepo } return new Maven2RepositoryLayout( + new ArrayList<>( checksumAlgorithmFactorySelector.getChecksumAlgorithmFactories() ), checksumsAlgorithms, omitChecksumsForExtensions ); @@ -150,15 +151,18 @@ public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepo private static class Maven2RepositoryLayout implements RepositoryLayout { + private final List allChecksumAlgorithms; - private final List checksumAlgorithms; + private final List configuredChecksumAlgorithms; private final Set extensionsWithoutChecksums; - private Maven2RepositoryLayout( List checksumAlgorithms, + private Maven2RepositoryLayout( List allChecksumAlgorithms, + List configuredChecksumAlgorithms, Set extensionsWithoutChecksums ) { - this.checksumAlgorithms = Collections.unmodifiableList( checksumAlgorithms ); + this.allChecksumAlgorithms = Collections.unmodifiableList( allChecksumAlgorithms ); + this.configuredChecksumAlgorithms = Collections.unmodifiableList( configuredChecksumAlgorithms ); this.extensionsWithoutChecksums = requireNonNull( extensionsWithoutChecksums ); } @@ -177,7 +181,7 @@ private URI toUri( String path ) @Override public List getChecksumAlgorithmFactories() { - return checksumAlgorithms; + return configuredChecksumAlgorithms; } @Override @@ -263,8 +267,8 @@ public List getChecksumLocations( Metadata metadata, boolean u private List getChecksumLocations( URI location ) { - List checksumLocations = new ArrayList<>( checksumAlgorithms.size() ); - for ( ChecksumAlgorithmFactory checksumAlgorithmFactory : checksumAlgorithms ) + List checksumLocations = new ArrayList<>( configuredChecksumAlgorithms.size() ); + for ( ChecksumAlgorithmFactory checksumAlgorithmFactory : configuredChecksumAlgorithms ) { checksumLocations.add( ChecksumLocation.forLocation( location, checksumAlgorithmFactory ) ); } @@ -273,7 +277,7 @@ private List getChecksumLocations( URI location ) private boolean isChecksum( String extension ) { - return checksumAlgorithms.stream().anyMatch( a -> extension.endsWith( "." + a.getFileExtension() ) ); + return allChecksumAlgorithms.stream().anyMatch( a -> extension.endsWith( "." + a.getFileExtension() ) ); } } } diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactoryTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactoryTest.java index 0fc7a293f..7b7fecf09 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactoryTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactoryTest.java @@ -331,6 +331,17 @@ public void testCustomChecksumsIgnored() assertEquals( 0, checksums.size() ); } + @Test + public void testNotConfiguredButSupportedChecksumsHandledAsChecksums() + throws Exception + { + layout = factory.newInstance( session, newRepo( "default" ) ); + DefaultArtifact artifact = new DefaultArtifact( "g.i.d", "a-i.d", "cls", "jar.sha512", "1.0" ); + URI uri = layout.getLocation( artifact, true ); + List checksums = layout.getChecksumLocations( artifact, true, uri ); + assertEquals( 0, checksums.size() ); + } + @Test public void testCustomChecksumsIgnored_IllegalInout() throws Exception