Skip to content

Apache Lucene open-source search software

Fix broken MBean test: new File(URL.getPath()) is the wrong way to create filenames from "file:" URLs coming from Classloader. The problem: some characters are escaped, e.g. the whitespace in my user's home directory. The correct way is to cast to URI using toURI() and invoking the URI-ctor in File (this is the "official" way to go).

Uwe Schindler07424bf64061
diff --git a/solr/src/test/org/apache/solr/SolrInfoMBeanTest.java b/solr/src/test/org/apache/solr/SolrInfoMBeanTest.java
index 7a1063ca4c1..b625a0e9d50 100644
--- a/solr/src/test/org/apache/solr/SolrInfoMBeanTest.java
+++ b/solr/src/test/org/apache/solr/SolrInfoMBeanTest.java
@@ -89,7 +89,7 @@ public class SolrInfoMBeanTest extends TestCase
String path = pckgname.replace('.', '/');
Enumeration<URL> resources = cld.getResources(path);
while (resources.hasMoreElements()) {
- directories.add(new File(resources.nextElement().getPath()));
+ directories.add(new File(resources.nextElement().toURI()));
}
ArrayList<Class> classes = new ArrayList<Class>();