mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 23:16:33 +00:00
Use try-with-resources.
This commit is contained in:
parent
bf1822c55e
commit
460abd7474
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user