Skip to content

Commit

Permalink
Ensure PathMatchingResourcePatternResolverTests run in native image
Browse files Browse the repository at this point in the history
See inline comments in commit for details.

See gh-29243
  • Loading branch information
sbrannen committed Oct 4, 2022
1 parent dd814b6 commit 31d98bf
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -200,15 +201,15 @@ private void assertExactSubPaths(String pattern, String pathPrefix, String... su
}

private String getPath(Resource resource) {
try {
// Tests fail if we use getURL(). They would also fail on Mac OS when using getURI()
// if the resource paths are not Unicode normalized.
// See: https://github.com/spring-projects/spring-framework/issues/29243
return resource.getFile().getPath();
}
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
// Tests fail if we use resouce.getURL().getPath(). They would also fail on Mac OS when
// using resouce.getURI().getPath() if the resource paths are not Unicode normalized.
//
// On the JVM, all tests should pass when using resouce.getFile().getPath(); however,
// we use FileSystemResource#getPath since this test class is sometimes run within a
// GraalVM native image which cannot support Path#toFile.
//
// See: https://github.com/spring-projects/spring-framework/issues/29243
return ((FileSystemResource) resource).getPath();
}

}

0 comments on commit 31d98bf

Please sign in to comment.