@Test public void testGenerateAdditionalUrlsFingerprint() throws MalformedURLException, URISyntaxException { final Set<URL> urls = new HashSet<>(); URL testUrl = Paths.get("src/test/resources/TestClassLoaderUtils/TestSuccess.jar").toUri().toURL(); urls.add(testUrl); String testFingerprint = ClassLoaderUtils.generateAdditionalUrlsFingerprint(urls); assertNotNull(testFingerprint); }
public static String generateAdditionalUrlsFingerprint(Set<URL> urls) { List<String> listOfUrls = urls.stream().map(Object::toString).collect(Collectors.toList()); StringBuffer urlBuffer = new StringBuffer(); 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("UTF-8"); byte[] bytesOfDigest = md.digest(bytesOfAdditionalUrls); return DatatypeConverter.printHexBinary(bytesOfDigest); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { LOGGER.error("Unable to generate fingerprint for the provided additional resources {}", new Object[]{urls, e}); return null; } }
ClassLoaderUtils { public static String generateAdditionalUrlsFingerprint(Set<URL> urls) { List<String> listOfUrls = urls.stream().map(Object::toString).collect(Collectors.toList()); StringBuffer urlBuffer = new StringBuffer(); 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("UTF-8"); byte[] bytesOfDigest = md.digest(bytesOfAdditionalUrls); return DatatypeConverter.printHexBinary(bytesOfDigest); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { LOGGER.error("Unable to generate fingerprint for the provided additional resources {}", new Object[]{urls, e}); return null; } } }
ClassLoaderUtils { public static String generateAdditionalUrlsFingerprint(Set<URL> urls) { List<String> listOfUrls = urls.stream().map(Object::toString).collect(Collectors.toList()); StringBuffer urlBuffer = new StringBuffer(); 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("UTF-8"); byte[] bytesOfDigest = md.digest(bytesOfAdditionalUrls); return DatatypeConverter.printHexBinary(bytesOfDigest); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { LOGGER.error("Unable to generate fingerprint for the provided additional resources {}", new Object[]{urls, e}); return null; } }  }
ClassLoaderUtils { public static String generateAdditionalUrlsFingerprint(Set<URL> urls) { List<String> listOfUrls = urls.stream().map(Object::toString).collect(Collectors.toList()); StringBuffer urlBuffer = new StringBuffer(); 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("UTF-8"); byte[] bytesOfDigest = md.digest(bytesOfAdditionalUrls); return DatatypeConverter.printHexBinary(bytesOfDigest); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { LOGGER.error("Unable to generate fingerprint for the provided additional resources {}", new Object[]{urls, e}); return null; } }  static ClassLoader getCustomClassLoader(String modulePath, ClassLoader parentClassLoader, FilenameFilter filenameFilter); static URL[] getURLsForClasspath(String modulePath, FilenameFilter filenameFilter, boolean suppressExceptions); static URL[] getURLsForClasspath(Set<String> modulePaths, FilenameFilter filenameFilter, boolean suppressExceptions); static String generateAdditionalUrlsFingerprint(Set<URL> urls); }
ClassLoaderUtils { public static String generateAdditionalUrlsFingerprint(Set<URL> urls) { List<String> listOfUrls = urls.stream().map(Object::toString).collect(Collectors.toList()); StringBuffer urlBuffer = new StringBuffer(); 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("UTF-8"); byte[] bytesOfDigest = md.digest(bytesOfAdditionalUrls); return DatatypeConverter.printHexBinary(bytesOfDigest); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { LOGGER.error("Unable to generate fingerprint for the provided additional resources {}", new Object[]{urls, e}); return null; } }  static ClassLoader getCustomClassLoader(String modulePath, ClassLoader parentClassLoader, FilenameFilter filenameFilter); static URL[] getURLsForClasspath(String modulePath, FilenameFilter filenameFilter, boolean suppressExceptions); static URL[] getURLsForClasspath(Set<String> modulePaths, FilenameFilter filenameFilter, boolean suppressExceptions); static String generateAdditionalUrlsFingerprint(Set<URL> urls);  }