You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/21 16:18:46 UTC
[commons-io] 02/05: Use try-with-resources
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-io.git
commit 7a6d0d59c67cb0e8ebdff8bdd7d7b77eb423653b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 21 09:46:47 2022 -0400
Use try-with-resources
---
src/test/java/org/apache/commons/io/IOCaseTest.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/IOCaseTest.java b/src/test/java/org/apache/commons/io/IOCaseTest.java
index aa77db94..a73aa2fa 100644
--- a/src/test/java/org/apache/commons/io/IOCaseTest.java
+++ b/src/test/java/org/apache/commons/io/IOCaseTest.java
@@ -31,8 +31,7 @@ import java.io.ObjectOutputStream;
import org.junit.jupiter.api.Test;
/**
- * This is used to test IOCase for correctness.
- *
+ * Tests {@link IOCase}.
*/
public class IOCaseTest {
@@ -40,10 +39,10 @@ public class IOCaseTest {
private IOCase serialize(final IOCase value) throws Exception {
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
- final ObjectOutputStream out = new ObjectOutputStream(buf);
- out.writeObject(value);
- out.flush();
- out.close();
+ try (final ObjectOutputStream out = new ObjectOutputStream(buf)) {
+ out.writeObject(value);
+ out.flush();
+ }
final ByteArrayInputStream bufin = new ByteArrayInputStream(buf.toByteArray());
final ObjectInputStream in = new ObjectInputStream(bufin);