Skip to content

Commit

Permalink
FLUME-722: RegexAllExtractor doesn't ignore empty groups (Mingjie Lai)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlai authored and Jonathan Hsieh committed Aug 9, 2011
1 parent 3d807d6 commit ed8e533
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Expand Up @@ -91,7 +91,7 @@ public void append(Event e) throws IOException, InterruptedException {
//Try/Catch so that we don't require there be the same number of names as patterns.
try {
//Ignore blank names. These are most likely sub patterns we don't care about keeping.
if(names.get(grp-1) != ""){
if (!"".equals(names.get(grp-1))) {
Attributes.setString(e, names.get(grp-1), val);
}
} catch (IndexOutOfBoundsException ioobe) {
Expand Down
Expand Up @@ -65,7 +65,7 @@ public void testRegexAllExtractor() throws IOException, InterruptedException {
mem.open();
ArrayList<String> names = new ArrayList<String>();
names.add("d1");
names.add("");
names.add(new String(""));
names.add("d2");

RegexAllExtractor re = new RegexAllExtractor(mem, "(\\d):(\\d):(\\d)",
Expand All @@ -79,6 +79,7 @@ public void testRegexAllExtractor() throws IOException, InterruptedException {
mem.open();
Event e1 = mem.next();
assertEquals("1", Attributes.readString(e1, "d1"));
assertEquals(null, Attributes.readString(e1, ""));
assertEquals("3", Attributes.readString(e1, "d2"));
}

Expand Down

0 comments on commit ed8e533

Please sign in to comment.