Skip to content

Apache Lucene open-source search software

The CSV loader incorrectly threw an exception when given header=true

Yonik Seeleyb627573cba7e
diff --git a/CHANGES.txt b/CHANGES.txt
index 235ee79c432..954c457f7fd 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -217,6 +217,10 @@ Bug Fixes
13. SOLR-413: Requesting a large numbers of documents to be returned (limit)
can result in an out-of-memory exception, even for a small index. (yonik)
+14. The CSV loader incorrectly threw an exception when given
+ header=true (the default). (ryan, yonik)
+
+
Other Changes
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the
build scripts to make two jars: apache-solr-1.3.jar and
diff --git a/src/java/org/apache/solr/handler/CSVRequestHandler.java b/src/java/org/apache/solr/handler/CSVRequestHandler.java
index d49cae91154..18a37f0e1bf 100755
--- a/src/java/org/apache/solr/handler/CSVRequestHandler.java
+++ b/src/java/org/apache/solr/handler/CSVRequestHandler.java
@@ -240,7 +240,7 @@ abstract class CSVLoader {
if (null == hasHeader) {
// assume the file has the headers if they aren't supplied in the args
hasHeader=true;
- } else if (hasHeader) {
+ } else if (!hasHeader) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"CSVLoader: must specify fieldnames=<fields>* or header=true");
}
} else {
diff --git a/src/test/org/apache/solr/handler/TestCSVLoader.java b/src/test/org/apache/solr/handler/TestCSVLoader.java
index a533cccd6d6..3d97441b4a1 100755
--- a/src/test/org/apache/solr/handler/TestCSVLoader.java
+++ b/src/test/org/apache/solr/handler/TestCSVLoader.java
@@ -123,6 +123,10 @@ public class TestCSVLoader extends AbstractSolrTestCase {
loadLocal("stream.file",filename, "commit","true");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ // test explicitly adding header=true (the default)
+ loadLocal("stream.file",filename, "commit","true","header","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+
// test no overwrites
loadLocal("stream.file",filename, "commit","true", "overwrite","false");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='8']");