elharo commented on code in PR #177:
URL: https://github.com/apache/maven-shared-jar/pull/177#discussion_r4147877959
##########
src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java:
##########
@@ -77,9 +83,13 @@ public void expose(JarIdentification identification,
JarAnalyzer jarAnalyzer) {
repohits.addAll(repositoryHashSearch.searchFileHash(hash));
}
- String bytecodehash = bytecodeHashAnalyzer.computeHash(jarAnalyzer);
- if (bytecodehash != null) {
-
repohits.addAll(repositoryHashSearch.searchBytecodeHash(bytecodehash));
+ try {
+ String bytecodehash =
bytecodeHashAnalyzer.computeHashCode(jarAnalyzer);
+ if (bytecodehash != null) {
Review Comment:
computeHashcode should now never return null
##########
src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java:
##########
@@ -43,25 +43,46 @@
public class JarBytecodeHashAnalyzer implements JarHashAnalyzer {
private final Logger logger = LoggerFactory.getLogger(getClass());
+ /**
+ * Computes the bytecode hash while retaining the historical null-on-error
behaviour.
+ *
+ * @param jarAnalyzer the JAR analyzer to use
+ * @return the hash, or {@code null} when the hash cannot be computed
+ * @deprecated use {@link #computeHashCode(JarAnalyzer)} when the failure
must be handled by the caller
+ */
+ @Deprecated
+ @Override
public String computeHash(JarAnalyzer jarAnalyzer) {
+ try {
+ return computeHashCode(jarAnalyzer);
+ } catch (IOException e) {
+ logger.warn("Unable to calculate the hashcode.", e);
+ return null;
+ }
+ }
+
+ /**
+ * Computes the bytecode hash and reports I/O failures to the caller.
+ *
+ * @param jarAnalyzer the JAR analyzer to use
+ * @return the computed hash
+ * @throws IOException if a class entry cannot be read
+ */
+ public String computeHashCode(JarAnalyzer jarAnalyzer) throws IOException {
Review Comment:
make this final
--
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]