Skip to content

Commit

Permalink
Fix UrlTokenFilter issue when no tokens are returned by UrlTokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
jlinn committed May 21, 2016
1 parent 8d983c0 commit 9d775c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ private boolean advance() throws IOException {
}
throw e;
}
if (tokens.isEmpty()) {
return false;
}
iterator = tokens.iterator();
return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testFilterPort() throws IOException {
@Test
public void testFilterPath() throws IOException {
assertTokenStreamContents(createFilter(TEST_HTTP_URL, URLPart.PATH).setTokenizePath(false), "/index_name/type_name/_search.html");
assertTokenStreamContents(createFilter(TEST_HTTP_URL2, URLPart.PATH).setTokenizePath(false), "");
assertTokenStreamContents(createFilter(TEST_HTTP_URL2, URLPart.PATH).setTokenizePath(false), new String[]{});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public void testTokenizePath() throws IOException {
}


@Test
public void testTokenizeNoPath() throws Exception {
final String url = "http://www.foo.bar.com:9200";
URLTokenizer tokenizer = createTokenizer(url, URLPart.PATH);
assertTokenStreamContents(tokenizer, stringArray());
}


@Test
public void testTokenizeQuery() throws IOException {
URLTokenizer tokenizer = createTokenizer(TEST_HTTP_URL, URLPart.QUERY);
Expand Down

0 comments on commit 9d775c7

Please sign in to comment.