Skip to content

Commit b3daff2

Browse files
committed
Better resource management.
1 parent e06b845 commit b3daff2

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/test/java/org/apache/commons/csv/issues/JiraCsv247Test.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ public void testHeadersMissingThrowsWhenNotAllowingMissingColumnNames() {
6767
assertFalse(format.getAllowMissingColumnNames(), "By default we should not allow missing column names");
6868

6969
assertThrows(IllegalArgumentException.class, () -> {
70-
try (final Reader in = new StringReader("a,,c,d,e\n1,2,3,4,5\nv,w,x,y,z")) {
71-
format.parse(in);
70+
try (final Reader reader = new StringReader("a,,c,d,e\n1,2,3,4,5\nv,w,x,y,z");
71+
CSVParser parser = format.parse(reader);) {
72+
// should fail
7273
}
7374
}, "1 missing column header is not allowed");
7475

7576
assertThrows(IllegalArgumentException.class, () -> {
76-
try (final Reader in = new StringReader("a,,c,d,\n1,2,3,4,5\nv,w,x,y,z")) {
77-
format.parse(in);
77+
try (final Reader reader = new StringReader("a,,c,d,\n1,2,3,4,5\nv,w,x,y,z");
78+
CSVParser parser = format.parse(reader);) {
79+
// should fail
7880
}
7981
}, "2+ missing column headers is not allowed!");
8082
}

0 commit comments

Comments
 (0)