Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

JIRA-2353: Config incorrectly handles Windows absolute pathnames

Shai Erera76dd311c5c3d
diff --git a/lucene/contrib/benchmark/CHANGES.txt b/lucene/contrib/benchmark/CHANGES.txt
index 6a486687a81..9bb10d8d600 100644
--- a/lucene/contrib/benchmark/CHANGES.txt
+++ b/lucene/contrib/benchmark/CHANGES.txt
@@ -2,6 +2,10 @@ Lucene Benchmark Contrib Change Log
The Benchmark contrib package contains code for benchmarking Lucene in a variety of ways.
+3/28/2010
+ LUCENE-2353: Fixed bug in Config where Windows absolute path property values
+ were incorrectly handled (Shai Erera via ?)
+
3/24/2010
LUCENE-2343: Added support for benchmarking collectors. (Grant Ingersoll, Shai Erera)
diff --git a/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java b/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
index 9bdb4c7e6da..ccb252553dd 100644
--- a/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
+++ b/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
@@ -139,6 +139,10 @@ public class Config {
}
if (sval.indexOf(":") < 0) {
return sval;
+ } else if (sval.indexOf(":\\") >= 0 || sval.indexOf(":/") >= 0) {
+ // this previously messed up absolute path names on Windows. Assuming
+ // there is no real value that starts with \ or /
+ return sval;
}
// first time this prop is extracted by round
int k = sval.indexOf(":");
diff --git a/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/utils/TestConfig.java b/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/utils/TestConfig.java
new file mode 100644
index 00000000000..469f4325773
--- /dev/null
+++ b/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/utils/TestConfig.java
@@ -0,0 +1,39 @@
+package org.apache.lucene.benchmark.byTask.utils;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.apache.lucene.util.LuceneTestCaseJ4;
+import org.junit.Test;
+
+public class TestConfig extends LuceneTestCaseJ4 {
+
+ @Test
+ public void testAbsolutePathNamesWindows() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("work.dir1", "c:\\temp");
+ props.setProperty("work.dir2", "c:/temp");
+ Config conf = new Config(props);
+ assertEquals("c:\\temp", conf.get("work.dir1", ""));
+ assertEquals("c:/temp", conf.get("work.dir2", ""));
+ }
+
+}