StephanEwen commented on a change in pull request #8282: [FLINK-12338] Update Apache Avro test to use try-with-resources URL: https://github.com/apache/flink/pull/8282#discussion_r280778538
########## File path: flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/EncoderDecoderTest.java ########## @@ -66,27 +66,28 @@ public void testComplexStringsDirecty() { ByteArrayOutputStream baos = new ByteArrayOutputStream(512); { - DataOutputStream dataOut = new DataOutputStream(baos); - DataOutputEncoder encoder = new DataOutputEncoder(); - encoder.setOut(dataOut); + try (DataOutputStream dataOut = new DataOutputStream(baos)) { + DataOutputEncoder encoder = new DataOutputEncoder(); + encoder.setOut(dataOut); - encoder.writeString(testString); - dataOut.flush(); - dataOut.close(); + encoder.writeString(testString); + dataOut.flush(); + } } byte[] data = baos.toByteArray(); // deserialize { - ByteArrayInputStream bais = new ByteArrayInputStream(data); - DataInputStream dataIn = new DataInputStream(bais); - DataInputDecoder decoder = new DataInputDecoder(); - decoder.setIn(dataIn); + try (ByteArrayInputStream bais = new ByteArrayInputStream(data)) { Review comment: same as above ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services