Skip to content

Commit

Permalink
manage windows issues with path for solr
Browse files Browse the repository at this point in the history
  • Loading branch information
jetoile committed Jan 5, 2016
1 parent eb49c51 commit 883476b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/main/java/fr/jetoile/sample/component/SolrBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ public enum SolrBootstrap implements Bootstrap {
}
build();
}
build();
}

private void build() {
try {
solrLocalCluster = new SolrEmbeddedServer(getClass().getClassLoader().getResource(solrDirectory).getFile(), solrCollection);
String path = getClass().getClassLoader().getResource(solrDirectory).getFile();
if (System.getProperty("os.name").startsWith("Windows")) {
path = path.substring(1);
}
solrLocalCluster = new SolrEmbeddedServer(path, solrCollection);
} catch (ParserConfigurationException | IOException | SAXException e) {
LOGGER.error("unable to bootstrap solr", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public final EmbeddedSolrServer createPathConfiguredSolrServer(String path) thro

if (StringUtils.isBlank(solrHomeDirectory)) {
solrHomeDirectory = getURL(path).getPath();
if (System.getProperty("os.name").startsWith("Windows")) {
solrHomeDirectory = solrHomeDirectory.substring(1);
}
}

solrHomeDirectory = URLDecoder.decode(solrHomeDirectory, "utf-8");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package fr.jetoile.sample.exception;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;

import javax.xml.parsers.ParserConfigurationException;

public class BootstrapException extends Exception {
public BootstrapException(String s, ConfigurationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import com.github.sakserv.minicluster.config.ConfigVars;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import fr.jetoile.sample.exception.BootstrapException;
import fr.jetoile.sample.Utils;
import org.apache.commons.configuration.Configuration;
Expand Down

0 comments on commit 883476b

Please sign in to comment.