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-bsf.git

commit 8e17106edf6197988a1148b5fa4f127af5936e5f
Author: Gary D. Gregory <[email protected]>
AuthorDate: Fri Jun 20 08:12:01 2025 -0400

    Use try-with-resources
---
 src/test/java/org/apache/bsf/util/StringUtilsTest.java | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/test/java/org/apache/bsf/util/StringUtilsTest.java 
b/src/test/java/org/apache/bsf/util/StringUtilsTest.java
index 9d2027a..2888e68 100644
--- a/src/test/java/org/apache/bsf/util/StringUtilsTest.java
+++ b/src/test/java/org/apache/bsf/util/StringUtilsTest.java
@@ -122,20 +122,15 @@ public class StringUtilsTest extends TestCase {
     }
 
     public void testGetContentAsReader() throws MalformedURLException, 
IOException {
-
-        Reader reader;
-
         final File myFile = File.createTempFile("Test", "txt");
-
         final FileWriter fw = new FileWriter(myFile);
         final PrintWriter pw = new PrintWriter(fw);
         pw.println("file name : Test.txt");
         pw.flush();
-
-        reader = StringUtils.getContentAsReader(myFile.toURL());
-        final BufferedReader bf = new BufferedReader(reader);
-        assertTrue(bf.readLine().equals("file name : Test.txt"));
-
+        try (Reader reader = StringUtils.getContentAsReader(myFile.toURL())) {
+            final BufferedReader bf = new BufferedReader(reader);
+            assertTrue(bf.readLine().equals("file name : Test.txt"));
+        }
     }
 
     public void testGetContentAsString() throws IOException {

Reply via email to