From 9ebcddc0b15c39f18c26b330acd3bfd921ef9bff Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 7 Mar 2022 15:27:28 -0500 Subject: [PATCH] Use try-with-resources. --- .../commons/lang3/event/EventListenerSupportTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java index facff22da..937133985 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java @@ -142,10 +142,9 @@ public class EventListenerSupportTest { //serialize: final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - final ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); - - objectOutputStream.writeObject(listenerSupport); - objectOutputStream.close(); + try (final ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream)) { + objectOutputStream.writeObject(listenerSupport); + } //deserialize: @SuppressWarnings("unchecked")