Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSEARCH-4947 - fixing loading jar files on windows #3719

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ else if ( "file".equals( codeSourceLocation.getProtocol() ) ) {
else {
// The URI points to a regular file, so hopefully an actual JAR file.
// We'll try to open a ZIP filesystem to work on the contents of the JAR file.
URI jarUri = new URI( "jar:file", null, path.toString(), null );
URI jarUri = new URI( "jar:file", null, codeSourceLocation.getPath(), null );
tryInitJarFileSystem( jarUri );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.hibernate.search.util.impl.test.annotation.TestForIssue;
import org.hibernate.search.util.impl.test.function.ThrowingConsumer;

import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -389,6 +390,17 @@ public void directory_specialCharacter() throws Exception {
}
}

@Test
public void initFileSystem_windowsJar() throws IOException {
Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("windows"));
Path jarPath = createJar( root -> {
addMetaInfFile( root );
addSimpleClass( root );
} );

new CodeSource(jarPath.toUri().toURL()).initFileSystem(); //Not getting an exception means it works
}

private Path createDir(ThrowingConsumer<Path, IOException> contributor) throws IOException {
Path dirPath = temporaryFolder.newFolder().toPath();
contributor.accept( dirPath );
Expand Down Expand Up @@ -424,5 +436,4 @@ private void addSimpleClass(Path classesDir) throws IOException {
private static URLClassLoader createIsolatedClassLoader(URL jarURL) {
return new URLClassLoader( new URL[] { jarURL }, null );
}

}