Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-7921: The techproducts example fails when running in a directory that contains spaces.

Timothy Potter5af08f721170
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 417d76da32b..23ab51c7e71 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -383,6 +383,10 @@ Bug Fixes
* SOLR-7908: SegmentsInfoRequestHandler gets a ref counted IndexWriter and does not properly release it.
(Mark Miller, shalin)
+* SOLR-7921: The techproducts example fails when running in a directory that contains spaces.
+ (Ishan Chattopadhyaya via Timothy Potter)
+
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index f26d9580b86..a882ca463b8 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -2150,25 +2150,16 @@ public class SolrCLI {
}
if (exampledocsDir.isDirectory()) {
- File postJarFile = new File(exampledocsDir, "post.jar");
String updateUrl = String.format(Locale.ROOT, "%s/%s/update", solrUrl, collectionName);
echo("Indexing tech product example docs from "+exampledocsDir.getAbsolutePath());
- if (postJarFile.isFile()) {
- String javaHome = System.getProperty("java.home");
- String java = javaHome+"/bin/java";
- String postCmd = String.format(Locale.ROOT, "%s -Durl=\"%s\" -jar %s \"%s\"/*.xml",
- java, updateUrl, postJarFile.getAbsolutePath(), exampledocsDir.getAbsolutePath());
- executor.execute(org.apache.commons.exec.CommandLine.parse(postCmd));
+
+ String currentPropVal = System.getProperty("url");
+ System.setProperty("url", updateUrl);
+ SimplePostTool.main(new String[] {exampledocsDir.getAbsolutePath()+"/*.xml"});
+ if (currentPropVal != null) {
+ System.setProperty("url", currentPropVal); // reset
} else {
- // a bit hacky, but just use SimplePostTool directly
- String currentPropVal = System.getProperty("url");
- System.setProperty("url", updateUrl);
- SimplePostTool.main(new String[] {exampledocsDir.getAbsolutePath()+"/*.xml"});
- if (currentPropVal != null) {
- System.setProperty("url", currentPropVal); // reset
- } else {
- System.clearProperty("url");
- }
+ System.clearProperty("url");
}
} else {
echo("exampledocs directory not found, skipping indexing step for the techproducts example");
diff --git a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
index ab1648d7f6a..d45893b07a3 100644
--- a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
+++ b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
@@ -158,34 +158,12 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
}
} else {
String cmdLine = joinArgs(cmd.getArguments());
- if (cmdLine.indexOf("post.jar") != -1) {
- // invocation of the post.jar file ... we'll just hit the SimplePostTool directly vs. trying to invoke another JVM
- List<String> argsToSimplePostTool = new ArrayList<String>();
- boolean afterPostJarArg = false;
- for (String arg : cmd.getArguments()) {
- if (arg.startsWith("-D")) {
- arg = arg.substring(2);
- int eqPos = arg.indexOf("=");
- System.setProperty(arg.substring(0,eqPos), arg.substring(eqPos+1));
- } else {
- if (arg.endsWith("post.jar")) {
- afterPostJarArg = true;
- } else {
- if (afterPostJarArg) {
- argsToSimplePostTool.add(arg);
- }
- }
- }
- }
- SimplePostTool.main(argsToSimplePostTool.toArray(new String[0]));
- } else {
- log.info("Executing command: "+cmdLine);
- try {
- return super.execute(cmd);
- } catch (Exception exc) {
- log.error("Execute command ["+cmdLine+"] failed due to: "+exc, exc);
- throw exc;
- }
+ log.info("Executing command: "+cmdLine);
+ try {
+ return super.execute(cmd);
+ } catch (Exception exc) {
+ log.error("Execute command ["+cmdLine+"] failed due to: "+exc, exc);
+ throw exc;
}
}
@@ -301,7 +279,6 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
}
}
- @Ignore
@Test
public void testTechproductsExample() throws Exception {
testExample("techproducts");