Skip to content

Commit aa4bf73

Browse files
committed
Merge branch '3.3.x' into 3.4.x
Closes gh-46027
2 parents 29f09c9 + 206785f commit aa4bf73

File tree

1 file changed

+9
-1
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/protocol/jar

1 file changed

+9
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/protocol/jar/JarFileUrlKey.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,6 +41,9 @@ private JarFileUrlKey() {
4141
* @return a {@link JarFileUrlKey} instance
4242
*/
4343
static String get(URL url) {
44+
if (!isCachableUrl(url)) {
45+
return create(url);
46+
}
4447
Map<URL, String> cache = (JarFileUrlKey.cache != null) ? JarFileUrlKey.cache.get() : null;
4548
if (cache == null) {
4649
cache = new ConcurrentHashMap<>();
@@ -49,6 +52,11 @@ static String get(URL url) {
4952
return cache.computeIfAbsent(url, JarFileUrlKey::create);
5053
}
5154

55+
private static boolean isCachableUrl(URL url) {
56+
// Don't cache URL that have a host since equals() will perform DNS lookup
57+
return url.getHost() == null || url.getHost().isEmpty();
58+
}
59+
5260
private static String create(URL url) {
5361
StringBuilder value = new StringBuilder();
5462
String protocol = url.getProtocol();

0 commit comments

Comments
 (0)