Skip to content
Permalink
Browse files
Use try-with-resources.
  • Loading branch information
garydgregory committed Nov 24, 2020
1 parent bf1822c commit 460abd7474e1a700f387298dedfb9fc217388389
Showing 2 changed files with 2 additions and 11 deletions.
@@ -283,14 +283,8 @@ static File makeTestFileObject(final String testFileName) {
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 @@ private static void assertIsAllowedClassNameFalse(final String className) {
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();
}

0 comments on commit 460abd7

Please sign in to comment.