Skip to content

Commit 2cdfd69

Browse files
committed
RegexDecoder should not emit null record ids.
Fixes issue #23
1 parent 024adf3 commit 2cdfd69

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/org/culturegraph/mf/stream/converter/RegexDecoder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ public void setDefaultLiteralName(final String defaultLiteralName) {
125125
public void process(final String string) {
126126
matcher.reset(string);
127127

128-
String id = null;
128+
final String id;
129129
final int groupIndex = captureGroupNames.indexOf(ID_CAPTURE_GROUP) + 1;
130130
if (groupIndex > 0 && matcher.find()) {
131131
id = matcher.group(groupIndex);
132+
} else {
133+
id = "";
132134
}
133135
getReceiver().startRecord(id);
134136

src/test/java/org/culturegraph/mf/stream/converter/RegexDecoderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class RegexDecoderTest {
4444
public void testRegex() {
4545
final EventList expected = new EventList();
4646

47-
expected.startRecord(null);
47+
expected.startRecord("");
4848
expected.literal(DEFAULT_LITERAL_NAME, INPUT);
4949
expected.literal(GROUP_NAME_1, "42");
5050
expected.literal(GROUP_NAME_2, "xyzzy");

0 commit comments

Comments
 (0)