This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git

commit e75b90a17ee53a27b72207671e4ba5f73a8c631f
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Sep 14 09:41:39 2024 -0400

    Use try-with-resources
---
 src/test/java/org/apache/commons/csv/CSVRecordTest.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java 
b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
index 65698f58..b1f61a14 100644
--- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
@@ -84,10 +84,11 @@ public class CSVRecordTest {
 
     @Test
     public void testCSVRecordNULLValues() throws IOException {
-        final CSVParser parser = CSVParser.parse("A,B\r\nONE,TWO", 
CSVFormat.DEFAULT.withHeader());
-        final CSVRecord csvRecord = new CSVRecord(parser, null, null, 0L, 0L);
-        assertEquals(0, csvRecord.size());
-        assertThrows(IllegalArgumentException.class, () -> csvRecord.get("B"));
+        try (CSVParser parser = CSVParser.parse("A,B\r\nONE,TWO", 
CSVFormat.DEFAULT.withHeader())) {
+            final CSVRecord csvRecord = new CSVRecord(parser, null, null, 0L, 
0L);
+            assertEquals(0, csvRecord.size());
+            assertThrows(IllegalArgumentException.class, () -> 
csvRecord.get("B"));
+        }
     }
 
     @Test

Reply via email to