From d1a29a63d2ea1552ce20bf2613330ff3fd5b740b Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 30 Jun 2015 11:15:55 +0200 Subject: [PATCH] Decode URL.getPath before resolving a real file URL with spaces are URL-Encoded and need to be decoded before they can be used to open files etc. --- core/src/main/java/org/elasticsearch/bootstrap/JarHell.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/bootstrap/JarHell.java b/core/src/main/java/org/elasticsearch/bootstrap/JarHell.java index 90fb38c68ee..2884da4fe1c 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/JarHell.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/JarHell.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.io.PathUtils; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; +import java.net.URLDecoder; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -55,12 +56,12 @@ class JarHell { final Map clazzes = new HashMap<>(32768); Set seenJars = new HashSet<>(); for (final URL url : ((URLClassLoader)loader).getURLs()) { - String path = url.getPath(); + String path = URLDecoder.decode(url.getPath(), "UTF-8"); if (path.endsWith(".jar")) { if (!seenJars.add(path)) { continue; // we can't fail because of sheistiness with joda-time } - try (JarFile file = new JarFile(url.getPath())) { + try (JarFile file = new JarFile(path)) { Manifest manifest = file.getManifest(); if (manifest != null) { // inspect Manifest: give a nice error if jar requires a newer java version