Skip to content

Commit b26fd24

Browse files
committed
Fix parameter check in RecordBuilder#setSystemChar()
The parameter check did not fail on indix values greater than 2 which exceeds the space for system chars in Marc 21 records. Fixes #283 (cherry picked from commit f96ef28)
1 parent 7313127 commit b26fd24

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void setSystemChars(final char[] systemChars) {
122122
}
123123

124124
public void setSystemChar(final int index, final char value) {
125-
Require.that(0 <= index && index < IMPL_CODES_LENGTH);
125+
Require.that(0 <= index && index < SYSTEM_CHARS_LENGTH);
126126
Require.that(value < Iso646Constants.MAX_CHAR_CODE);
127127
label.setSystemChar(index, value);
128128
}

metafacture-biblio/src/test/java/org/metafacture/biblio/iso2709/RecordBuilderTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public void shouldThrowExceptionIfSystemCharsIsNull() {
183183
builder.setSystemChars(null); // Exception expected
184184
}
185185

186+
@Test(expected = IllegalArgumentException.class)
187+
public void shouldThrowExceptionIfSystemCharIndexGreaterThan2() {
188+
builder.setSystemChar(3, '1');
189+
}
190+
186191
@Test
187192
public void shouldWriteReserverdCharToRecordLabel() {
188193
builder.setReservedChar('R');

0 commit comments

Comments
 (0)