Permalink
Browse files

FLUME-722: RegexAllExtractor doesn't ignore empty groups (Mingjie Lai)

  • Loading branch information...
1 parent 3d807d6 commit ed8e533ae26b4e355f692b81aa42b8f0914736f1 @mlai mlai committed with jmhsieh Aug 9, 2011
@@ -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) {
@@ -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)",
@@ -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"));
}

0 comments on commit ed8e533

Please sign in to comment.