Use try-with-resources.
This commit is contained in:
parent
bf1822c55e
commit
460abd7474
|
@ -283,14 +283,8 @@ class HttpByteArrayCacheEntrySerializerTestUtils {
|
|||
static void saveEntryToFile(final HttpCacheEntrySerializer<byte[]> serializer, final HttpCacheStorageEntry httpCacheStorageEntry, final File outFile) throws Exception {
|
||||
final byte[] bytes = serializer.serialize(httpCacheStorageEntry);
|
||||
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(outFile);
|
||||
try (OutputStream out = new FileOutputStream(outFile)) {
|
||||
out.write(bytes);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,11 +240,8 @@ public class TestByteArrayCacheEntrySerializer {
|
|||
private byte[] serializeProhibitedObject() throws IOException {
|
||||
final BigDecimal bigDecimal = new BigDecimal("1000.00");
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
try {
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||
oos.writeObject(bigDecimal);
|
||||
} finally {
|
||||
oos.close();
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue