mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-23 09:49:01 +00:00
Merge branch '3.4.x'
Closes gh-46028
This commit is contained in:
+9
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,6 +41,9 @@ final class JarFileUrlKey {
|
||||
* @return a {@link JarFileUrlKey} instance
|
||||
*/
|
||||
static String get(URL url) {
|
||||
if (!isCachableUrl(url)) {
|
||||
return create(url);
|
||||
}
|
||||
Map<URL, String> cache = (JarFileUrlKey.cache != null) ? JarFileUrlKey.cache.get() : null;
|
||||
if (cache == null) {
|
||||
cache = new ConcurrentHashMap<>();
|
||||
@@ -49,6 +52,11 @@ final class JarFileUrlKey {
|
||||
return cache.computeIfAbsent(url, JarFileUrlKey::create);
|
||||
}
|
||||
|
||||
private static boolean isCachableUrl(URL url) {
|
||||
// Don't cache URL that have a host since equals() will perform DNS lookup
|
||||
return url.getHost() == null || url.getHost().isEmpty();
|
||||
}
|
||||
|
||||
private static String create(URL url) {
|
||||
StringBuilder value = new StringBuilder();
|
||||
String protocol = url.getProtocol();
|
||||
|
||||
Reference in New Issue
Block a user