elharo commented on code in PR #2008:
URL: https://github.com/apache/maven-resolver/pull/2008#discussion_r3644772600


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java:
##########
@@ -50,10 +53,11 @@
 @Singleton
 @Named
 public class DefaultRepositorySystemValidator implements 
RepositorySystemValidator {
-    private final List<ValidatorFactory> validatorFactories;
+    private static final Object SESSION_VALIDATORS = 
Keys.of(DefaultRepositorySystemValidator.class, "validators");
+    private final Map<String, ValidatorFactory> validatorFactories;
 
     @Inject
-    public DefaultRepositorySystemValidator(List<ValidatorFactory> 
validatorFactories) {
+    public DefaultRepositorySystemValidator(Map<String, ValidatorFactory> 
validatorFactories) {

Review Comment:
   public API change



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java:
##########
@@ -89,19 +106,21 @@ public void validateVersionRequest(RepositorySystemSession 
session, VersionReque
     @Override
     public void validateVersionRangeRequest(RepositorySystemSession session, 
VersionRangeRequest request) {
         ArrayList<Exception> exceptions = new ArrayList<>();
-        for (ValidatorFactory factory : validatorFactories) {
-            Validator validator = factory.newInstance(session);
-            try {
-                validator.validateArtifact(request.getArtifact());
-            } catch (Exception e) {
-                exceptions.add(e);
-            }
-            for (RemoteRepository repository : request.getRepositories()) {
+        for (Map.Entry<String, ValidatorFactory> entry : 
validatorFactories.entrySet()) {
+            Validator validator = newInstance(session, entry.getKey(), 
entry.getValue());
+            if (validator != ValidatorFactory.NOOP) {

Review Comment:
   do we really need all these if (validator != ValidatorFactory.NOOP) checks? 
If it's Validator.NOOP then the validator doesn't throw any exceptions, nothing 
is added to the exceptions list, and we get exactly the same result. It feels 
cleaner to just treat Validator.NOOP like every other one.



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java:
##########
@@ -50,10 +53,11 @@
 @Singleton
 @Named
 public class DefaultRepositorySystemValidator implements 
RepositorySystemValidator {
-    private final List<ValidatorFactory> validatorFactories;
+    private static final Object SESSION_VALIDATORS = 
Keys.of(DefaultRepositorySystemValidator.class, "validators");
+    private final Map<String, ValidatorFactory> validatorFactories;

Review Comment:
   I'm sure there's a reason but I don't immediately see what the String key is 
here or why we need it. A comment might be helpful.



-- 
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]

Reply via email to