Use try-with-resources.

This commit is contained in:
Gary Gregory 2022-03-07 15:27:28 -05:00
parent e3e020fe2f
commit 9ebcddc0b1
1 changed files with 3 additions and 4 deletions

View File

@ -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")