exceptionfactory commented on a change in pull request #4788:
URL: https://github.com/apache/nifi/pull/4788#discussion_r576441917



##########
File path: 
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/FileUtils.java
##########
@@ -541,57 +540,30 @@ public static void syncWithRestore(final File 
primaryFile, final File restoreFil
     }
 
     /**
-     * Returns true if the given files are the same according to their MD5 
hash.
+     * Returns true if the given files are the same according to their hash.
      *
      * @param file1 a file
      * @param file2 a file
      * @return true if the files are the same; false otherwise
-     * @throws IOException if the MD5 hash could not be computed
+     * @throws IOException if the hash could not be computed
      */
     public static boolean isSame(final File file1, final File file2) throws 
IOException {
-        return Arrays.equals(computeMd5Digest(file1), computeMd5Digest(file2));
+        return Arrays.equals(computeDigest(file1), computeDigest(file2));
     }
 
     /**
-     * Returns the MD5 hash of the given file.
+     * Returns the hash of the given file using default digest algorithm
      *
      * @param file a file
-     * @return the MD5 hash
-     * @throws IOException if the MD5 hash could not be computed
+     * @return Digest Hash Bytes
+     * @throws IOException if the hash could not be computed
      */
-    public static byte[] computeMd5Digest(final File file) throws IOException {
+    public static byte[] computeDigest(final File file) throws IOException {
         try (final FileInputStream fis = new FileInputStream(file)) {
-            return computeMd5Digest(fis);
+            return MessageDigestUtils.getDigest(fis);
         }
     }
 
-    /**
-     * Returns the MD5 hash of the given stream.
-     *
-     * @param stream an input stream
-     * @return the MD5 hash
-     * @throws IOException if the MD5 hash could not be computed
-     */
-    public static byte[] computeMd5Digest(final InputStream stream) throws 
IOException {

Review comment:
       This is a good point to consider.  Should all public methods in classes 
outside of API modules be considered part of the semantically versioned API?  
Perhaps more specifically, should classes in utility modules be considered part 
of the public API?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to