Skip to content

Commit 8761ef5

Browse files
committed
Log single message per jar with faulty Class-Path manifest attribute
Previously, when DevTools encountered a jar with a Class-Path manifest attribute that referenced non-existent files, it would log one message per entry in the attribute that did not exist. While useful information, this has proven to be too verbose. This commit aims to strike a better balances by logging a single message for an entire jar. The message is a single line that includes the path to the jar with the faulty Class-Path manifest attribute and the paths of all of the files that do not exist that are referenced by the attribute. Closes gh-10111
1 parent 9f1d435 commit 8761ef5

File tree

1 file changed

+7
-3
lines changed
  • spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart

1 file changed

+7
-3
lines changed

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,27 @@ private static List<URL> getUrlsFromManifestClassPathAttribute(JarFile jarFile)
140140
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
141141
List<URL> urls = new ArrayList<URL>(entries.length);
142142
File parent = new File(jarFile.getName()).getParentFile();
143+
List<File> nonExistentEntries = new ArrayList<File>();
143144
for (String entry : entries) {
144145
try {
145146
File referenced = new File(parent, entry);
146147
if (referenced.exists()) {
147148
urls.add(referenced.toURI().toURL());
148149
}
149150
else {
150-
System.out.println("Ignoring Class-Path entry " + entry + " found in "
151-
+ jarFile.getName() + " as " + referenced
152-
+ " does not exist");
151+
nonExistentEntries.add(referenced);
153152
}
154153
}
155154
catch (MalformedURLException ex) {
156155
throw new IllegalStateException(
157156
"Class-Path attribute contains malformed URL", ex);
158157
}
159158
}
159+
if (!nonExistentEntries.isEmpty()) {
160+
System.out.println("The Class-Path manifest attribute in " + jarFile.getName()
161+
+ " referenced one or more files that do not exist: "
162+
+ StringUtils.collectionToCommaDelimitedString(nonExistentEntries));
163+
}
160164
return urls;
161165
}
162166

0 commit comments

Comments
 (0)