[
https://issues.apache.org/jira/browse/FLUME-722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13079883#comment-13079883
]
Jonathan Hsieh commented on FLUME-722:
--------------------------------------
Actually, instead of the previous comment, this is a smaller and better change
that better demonstrates the root cause. (second call to names.add different
and added an assert).
Can you modify the existing function to be this instead?
{code}
@Test
public void testRegexAllExtractor() throws IOException, InterruptedException {
MemorySinkSource mem = new MemorySinkSource();
mem.open();
ArrayList<String> names = new ArrayList<String>();
names.add("d1");
// when parsed, a separate instance of "" is created
names.add(new String(new byte[0]));
names.add("d2");
RegexAllExtractor re = new RegexAllExtractor(mem, "(\\d):(\\d):(\\d)",
names);
re.open();
re.append(new EventImpl("1:2:3.4foobar5".getBytes()));
re.close();
mem.close();
mem.open();
Event e1 = mem.next();
assertEquals("1", Attributes.readString(e1, "d1"));
assertEquals(null, Attributes.readString(e1, ""));
assertEquals("3", Attributes.readString(e1, "d2"));
}
{code}
Thanks,
Jon.
> RegexAllExtractor doesn't ignore empty groups
> ---------------------------------------------
>
> Key: FLUME-722
> URL: https://issues.apache.org/jira/browse/FLUME-722
> Project: Flume
> Issue Type: Bug
> Components: Sinks+Sources
> Affects Versions: v0.9.4
> Reporter: Nicholas Verbeck
> Assignee: Mingjie Lai
> Priority: Minor
> Labels: decorator, regexall
> Attachments: FLUME-722.patch
>
>
> Hi flume devs.
> I saw a bug when using RegexAllExtractor: line 94:
> if(names.get(grp-1) != ""){
> Attributes.setString(e, names.get(grp-1), val);
> }
> Please help to file a jira and correct it to use String.equal(), otherwise it
> doesn't ignore empty groups.
> (I don't think I can open a issue at cloudera jira.)
> Thanks,
> Mingjie
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira