exceptionfactory commented on a change in pull request #4788:
URL: https://github.com/apache/nifi/pull/4788#discussion_r574092517
##########
File path:
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/classloader/ClassLoaderUtils.java
##########
@@ -143,19 +143,13 @@ public static String
generateAdditionalUrlsFingerprint(Set<URL> urls) {
//Sorting so that the order is maintained for generating the
fingerprint
Collections.sort(listOfUrls);
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- listOfUrls.forEach(url -> {
-
urlBuffer.append(url).append("-").append(getLastModified(url)).append(";");
- });
- byte[] bytesOfAdditionalUrls =
urlBuffer.toString().getBytes(StandardCharsets.UTF_8);
- byte[] bytesOfDigest = md.digest(bytesOfAdditionalUrls);
-
- return DatatypeConverter.printHexBinary(bytesOfDigest);
- } catch (NoSuchAlgorithmException e) {
- LOGGER.error("Unable to generate fingerprint for the provided
additional resources {}", new Object[]{urls, e});
- return null;
- }
+ listOfUrls.forEach(url -> {
Review comment:
The `StringBuffer` declaration was not part of this initial change, but
there doesn't appear to be any need for it, so will replace with
`StringBuilder` and use an expression lambda.
##########
File path:
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/security/MessageDigestUtils.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.util.security;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Message Digest Utilities for standardized algorithm use within the framework
+ */
+public class MessageDigestUtils {
Review comment:
That seems reasonable, will make the changes.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/FileDigestUtils.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.nar;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * File Digest Utilities for standardized algorithm use within NAR Unpacker
+ */
+public class FileDigestUtils {
Review comment:
Will make the changes.
----------------------------------------------------------------
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:
[email protected]