Browse Source

Adapt to new GraalVM metadata format

This commit updates our web resources patterns due to a change in the
GraalVM metadata format. Previously a single `*` was considering a
directory and its sub-folders. The same behavior now requires two `*`.

Closes gh-47894
pull/47903/head
Stéphane Nicoll 2 months ago
parent
commit
f11e3f3877
  1. 2
      core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHints.java
  2. 4
      core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.java

2
core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHints.java

@ -39,7 +39,7 @@ public class WebResourcesRuntimeHints implements RuntimeHintsRegistrar { @@ -39,7 +39,7 @@ public class WebResourcesRuntimeHints implements RuntimeHintsRegistrar {
ClassLoader classLoaderToUse = (classLoader != null) ? classLoader : getClass().getClassLoader();
String[] locations = DEFAULT_LOCATIONS.stream()
.filter((candidate) -> classLoaderToUse.getResource(candidate) != null)
.map((location) -> location + "*")
.map((location) -> location + "**")
.toArray(String[]::new);
if (locations.length > 0) {
hints.resources().registerPattern((hint) -> hint.includes(locations));

4
core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.java

@ -44,13 +44,13 @@ class WebResourcesRuntimeHintsTests { @@ -44,13 +44,13 @@ class WebResourcesRuntimeHintsTests {
RuntimeHints hints = register(
new TestClassLoader(List.of("META-INF/resources/", "resources/", "static/", "public/")));
assertThat(hints.resources().resourcePatternHints()).singleElement()
.satisfies(include("META-INF/resources/*", "resources/*", "static/*", "public/*"));
.satisfies(include("META-INF/resources/**", "resources/**", "static/**", "public/**"));
}
@Test
void registerHintsWithOnlyStaticLocations() {
RuntimeHints hints = register(new TestClassLoader(List.of("static/")));
assertThat(hints.resources().resourcePatternHints()).singleElement().satisfies(include("static/*"));
assertThat(hints.resources().resourcePatternHints()).singleElement().satisfies(include("static/**"));
}
@Test

Loading…
Cancel
Save