Skip to content

Commit e81b50f

Browse files
committed
Fix jar uri parsing in CloseablePath
Jar uris follow the format[1]: ``` jar:<url>!/[<entry>] ``` So splitting should be done on the last `!/` rather than the first. Fixes: #1724 for Spring Boot 3.2 and later. 1. https://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html
1 parent 8f5fbd0 commit e81b50f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

junit-platform-commons/src/main/java/org/junit/platform/commons/util/CloseablePath.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class CloseablePath implements Closeable {
3535
private static final String FILE_URI_SCHEME = "file";
3636
static final String JAR_URI_SCHEME = "jar";
3737
private static final String JAR_FILE_EXTENSION = ".jar";
38-
private static final String JAR_URI_SEPARATOR = "!";
38+
private static final String JAR_URI_SEPARATOR = "!/";
3939

4040
private static final Closeable NULL_CLOSEABLE = () -> {
4141
};
@@ -53,9 +53,11 @@ static CloseablePath create(URI uri) throws URISyntaxException {
5353

5454
static CloseablePath create(URI uri, FileSystemProvider fileSystemProvider) throws URISyntaxException {
5555
if (JAR_URI_SCHEME.equals(uri.getScheme())) {
56-
String[] parts = uri.toString().split(JAR_URI_SEPARATOR);
57-
String jarUri = parts[0];
58-
String jarEntry = parts[1];
56+
// Parsing: jar:<url>!/[<entry>]
57+
String uriString = uri.toString();
58+
int lastJarUriSeparator = uriString.lastIndexOf(JAR_URI_SEPARATOR);
59+
String jarUri = uriString.substring(0, lastJarUriSeparator);
60+
String jarEntry = uriString.substring(lastJarUriSeparator + 1);
5961
return createForJarFileSystem(new URI(jarUri), fileSystem -> fileSystem.getPath(jarEntry),
6062
fileSystemProvider);
6163
}

0 commit comments

Comments
 (0)