You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/01/12 07:51:49 UTC

[GitHub] [maven-resolver] michael-o commented on a change in pull request #89: [MRESOLVER-158] Simplify SimpleDigest

michael-o commented on a change in pull request #89:
URL: https://github.com/apache/maven-resolver/pull/89#discussion_r555570883



##########
File path: maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleDigest.java
##########
@@ -32,26 +35,23 @@
 
     private static final String[] HASH_ALGOS = new String[] { "SHA-1", "MD5" };
 
-    private MessageDigest digest;
-
-    private long hash;
+    private final MessageDigest digest;
 
     SimpleDigest()
     {
+        MessageDigest md = null;
         for ( String hashAlgo : HASH_ALGOS )
         {
             try
             {
-                digest = MessageDigest.getInstance( hashAlgo );
-                hash = 0;
+                md = MessageDigest.getInstance( hashAlgo );
                 break;
             }
             catch ( NoSuchAlgorithmException ne )
             {
-                digest = null;
-                hash = 13;
             }
         }
+        this.digest = requireNonNull( md, "Not supported digests: " + Arrays.toString( HASH_ALGOS ) );

Review comment:
       I think this should be IllegalStateException because no null has been passed, but an argument led to an inconsistent state.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org