From 33129ba46724176c9853c824c80e80ec21991643 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 14 Sep 2024 09:44:01 -0400 Subject: [PATCH] Use try-with-resources --- src/test/java/org/apache/commons/csv/LexerTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/csv/LexerTest.java b/src/test/java/org/apache/commons/csv/LexerTest.java index 3bc55a00..e6ccaea5 100644 --- a/src/test/java/org/apache/commons/csv/LexerTest.java +++ b/src/test/java/org/apache/commons/csv/LexerTest.java @@ -452,8 +452,9 @@ public class LexerTest { @Test public void testTrimTrailingSpacesZeroLength() throws Exception { final StringBuilder buffer = new StringBuilder(""); - final Lexer lexer = createLexer(buffer.toString(), CSVFormat.DEFAULT); - lexer.trimTrailingSpaces(buffer); - assertThat(lexer.nextToken(new Token()), matches(EOF, "")); + try (Lexer lexer = createLexer(buffer.toString(), CSVFormat.DEFAULT)) { + lexer.trimTrailingSpaces(buffer); + assertThat(lexer.nextToken(new Token()), matches(EOF, "")); + } } }