1
0

Use try-with-resources

This commit is contained in:
Gary Gregory
2023-11-26 10:18:14 -05:00
parent 6400cd0bc0
commit a1c174c086

View File

@@ -193,14 +193,13 @@ public class DefaultConfigTestCase extends TestCase {
// Serialize and deserialize the instance // Serialize and deserialize the instance
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos); try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(log); oos.writeObject(log);
oos.close(); }
final ByteArrayInputStream bais = final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
new ByteArrayInputStream(baos.toByteArray()); try (ObjectInputStream ois = new ObjectInputStream(bais)) {
final ObjectInputStream ois = new ObjectInputStream(bais);
log = (Log) ois.readObject(); log = (Log) ois.readObject();
ois.close(); }
// Check the characteristics of the resulting object // Check the characteristics of the resulting object
checkStandard(); checkStandard();