mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
HttpDiscovery: Fix resource leak as a result of unclosed GZIPInputStream.
This commit is contained in:
committed by
Andreas Schildbach
parent
5a08847e42
commit
a20087eee3
@@ -94,8 +94,13 @@ public class HttpDiscovery implements PeerDiscovery {
|
||||
throw new PeerDiscoveryException("HTTP request failed: " + response.code() + " " + response.message());
|
||||
InputStream stream = response.body().byteStream();
|
||||
GZIPInputStream zip = new GZIPInputStream(stream);
|
||||
PeerSeedProtos.SignedPeerSeeds proto = PeerSeedProtos.SignedPeerSeeds.parseDelimitedFrom(zip);
|
||||
stream.close();
|
||||
PeerSeedProtos.SignedPeerSeeds proto;
|
||||
try {
|
||||
proto = PeerSeedProtos.SignedPeerSeeds.parseDelimitedFrom(zip);
|
||||
} finally {
|
||||
zip.close(); // will close InputStream as well
|
||||
}
|
||||
|
||||
return protoToAddrs(proto);
|
||||
} catch (PeerDiscoveryException e1) {
|
||||
throw e1;
|
||||
|
Reference in New Issue
Block a user