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

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

commit 1f31a6b299f115508566e3a1d86ba4521d4ff9dc
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Aug 25 12:01:53 2024 -0400

    Use try-with-resources
---
 .../apache/commons/fileupload/StreamingTest.java   | 28 +++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/test/java/org/apache/commons/fileupload/StreamingTest.java 
b/src/test/java/org/apache/commons/fileupload/StreamingTest.java
index f1ed55f8..9176cdd8 100644
--- a/src/test/java/org/apache/commons/fileupload/StreamingTest.java
+++ b/src/test/java/org/apache/commons/fileupload/StreamingTest.java
@@ -55,22 +55,22 @@ public class StreamingTest {
 
     private byte[] newRequest() throws IOException {
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        final OutputStreamWriter osw = new OutputStreamWriter(baos, 
"US-ASCII");
-        int add = 16;
-        int num = 0;
-        for (int i = 0;  i < 16384;  i += add) {
-            if (++add == 32) {
-                add = 16;
-            }
-            osw.write(getHeader("field" + num++));
-            osw.flush();
-            for (int j = 0;  j < i;  j++) {
-                baos.write((byte) j);
+        try (OutputStreamWriter osw = new OutputStreamWriter(baos, 
"US-ASCII")) {
+            int add = 16;
+            int num = 0;
+            for (int i = 0; i < 16384; i += add) {
+                if (++add == 32) {
+                    add = 16;
+                }
+                osw.write(getHeader("field" + num++));
+                osw.flush();
+                for (int j = 0; j < i; j++) {
+                    baos.write((byte) j);
+                }
+                osw.write("\r\n");
             }
-            osw.write("\r\n");
+            osw.write(getFooter());
         }
-        osw.write(getFooter());
-        osw.close();
         return baos.toByteArray();
     }
 

Reply via email to