Merge "Fix handling of empty corpus queries"
diff --git a/Changes b/Changes
index dabde93..51adfa2 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
-0.37 2020-10-23
+0.37 2020-11-19
- [feature] Introduced query references in Poliqarp (diewald)
+ - [bugfix] Ignore empty corpus queries (diewald)
0.36 2020-07-24
- [security] Upgraded version of Google Guava
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
index c2e14e9..c74e155 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
@@ -60,6 +60,9 @@
@Override
public void process (String query) {
+ if (query == null || query.length() == 0)
+ return;
+
ParseTree tree = parseCollectionQuery(query);
if (this.parser != null) {
super.parser = this.parser;
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java
index 8f371de..5f97e40 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java
@@ -95,6 +95,16 @@
@Test
+ public void testEmpty () throws JsonProcessingException, IOException {
+ collection = "";
+ qs.setQuery(query, ql);
+ qs.setCollection(collection);
+ res = mapper.readTree(qs.toJSON());
+ assertFalse("Empty", res.has("/collection"));
+ }
+
+
+ @Test
public void testSimple () throws JsonProcessingException, IOException {
collection = "textClass=politik";
qs.setQuery(query, ql);