michael-o commented on a change in pull request #139:
URL: https://github.com/apache/maven-resolver/pull/139#discussion_r768837596
##########
File path:
maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/ChecksumCalculator.java
##########
@@ -125,7 +131,14 @@ private ChecksumCalculator( File targetFile,
Collection<RepositoryLayout.Checksu
String algo = checksum.getAlgorithm();
if ( algos.add( algo ) )
{
- this.checksums.add( new Checksum( algo ) );
+ try
+ {
+ this.checksums.add( new Checksum( algo, selector.select(
algo ) ) );
+ }
+ catch ( NoSuchAlgorithmException e )
+ {
+ this.checksums.add( new Checksum( algo, e ) );
Review comment:
I never liked this abuse approach, but should not be addressed here.
##########
File path:
maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/ChecksumValidator.java
##########
@@ -65,26 +66,32 @@ boolean fetchChecksum( URI remote, File local )
private final Collection<Checksum> checksums;
+ private final ChecksumImplementationSelector
checksumImplementationSelector;
+
private final Map<File, Object> checksumFiles;
- ChecksumValidator( File dataFile, FileProcessor fileProcessor,
- ChecksumFetcher checksumFetcher, ChecksumPolicy
checksumPolicy,
- Collection<Checksum> checksums )
+ ChecksumValidator( File dataFile,
+ FileProcessor fileProcessor,
+ ChecksumFetcher checksumFetcher,
+ ChecksumPolicy checksumPolicy,
+ Collection<Checksum> checksums,
+ ChecksumImplementationSelector
checksumImplementationSelector )
Review comment:
This order is not consistent with other ctors. In other ctors you have
added the selector after the checksum policy. Did you do this for backward
compat?
##########
File path:
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultChecksumImplementationSelector.java
##########
@@ -0,0 +1,75 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.security.NoSuchAlgorithmException;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.eclipse.aether.spi.connector.checksum.ChecksumImplementation;
+import
org.eclipse.aether.spi.connector.checksum.ChecksumImplementationSelectorSupport;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Default implementation of {@link
org.eclipse.aether.spi.connector.checksum.ChecksumImplementationSelector} that
+ * is extensible.
+ *
+ * @since TBD
+ */
+@Singleton
+@Named
+public final class DefaultChecksumImplementationSelector
+ extends ChecksumImplementationSelectorSupport
+{
+ private final Map<String, Provider<ChecksumImplementation>> providers;
+
+ /**
+ * Ctor for ServiceLocator.
+ */
+ public DefaultChecksumImplementationSelector()
Review comment:
You should deprecate this ctor right away since it is going to be
removed anyway.
##########
File path:
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumImplementation.java
##########
@@ -0,0 +1,41 @@
+package org.eclipse.aether.spi.connector.checksum;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.nio.ByteBuffer;
+
+/**
+ * Implementation performing checksum calculation for specific algorithm.
Instances of this interface as stateful,
+ * should be reused only after {@link #reset()}.
+ *
+ * <strong>Important note:</strong> if implementation of this interface is
component, it MUST NOT be singleton, but
Review comment:
Correct!
##########
File path:
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumImplementation.java
##########
@@ -0,0 +1,41 @@
+package org.eclipse.aether.spi.connector.checksum;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.nio.ByteBuffer;
+
+/**
+ * Implementation performing checksum calculation for specific algorithm.
Instances of this interface as stateful,
Review comment:
as => are
##########
File path:
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumImplementation.java
##########
@@ -0,0 +1,41 @@
+package org.eclipse.aether.spi.connector.checksum;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.nio.ByteBuffer;
+
+/**
+ * Implementation performing checksum calculation for specific algorithm.
Instances of this interface as stateful,
+ * should be reused only after {@link #reset()}.
+ *
+ * <strong>Important note:</strong> if implementation of this interface is
component, it MUST NOT be singleton, but
+ * must adhere to "prototype" pattern. Alternative is just to implement a
provider, and on each get invocation create
+ * new instance.
+ *
+ * @since TBD
+ */
+public interface ChecksumImplementation
+{
+ void update( ByteBuffer input );
+
+ void reset();
+
+ byte[] digest();
Review comment:
Should be renamed
##########
File path:
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultChecksumImplementationSelector.java
##########
@@ -0,0 +1,75 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.security.NoSuchAlgorithmException;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.eclipse.aether.spi.connector.checksum.ChecksumImplementation;
+import
org.eclipse.aether.spi.connector.checksum.ChecksumImplementationSelectorSupport;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Default implementation of {@link
org.eclipse.aether.spi.connector.checksum.ChecksumImplementationSelector} that
+ * is extensible.
+ *
+ * @since TBD
+ */
+@Singleton
+@Named
+public final class DefaultChecksumImplementationSelector
Review comment:
This isn't a default impl, but rather a `delegating`/`fallback`
implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]