Merge branch '1758-release-timeout-monitor-resources' into 'master'

Ensure TimeoutInputStreams are closed

Closes #1758

See merge request briar/briar!1273
This commit is contained in:
Torsten Grote
2020-08-14 11:00:49 +00:00
3 changed files with 6 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ class AndroidBluetoothTransportConnection
protected void closeConnection(boolean exception) throws IOException {
try {
socket.close();
in.close();
} finally {
wakeLock.release();
connectionLimiter.connectionClosed(this);

View File

@@ -7,6 +7,10 @@ public interface TimeoutMonitor {
/**
* Returns an {@link InputStream} that wraps the given stream and allows
* read timeouts to be detected.
* <p>
* The returned stream must be {@link InputStream#close() closed} when it's
* no longer needed to ensure that resources held by the timeout monitor
* are released.
*
* @param timeoutMs The read timeout in milliseconds. Timeouts will be
* detected eventually but are not guaranteed to be detected immediately.

View File

@@ -46,6 +46,7 @@ class JavaBluetoothTransportConnection
protected void closeConnection(boolean exception) throws IOException {
try {
socket.close();
in.close();
} finally {
connectionLimiter.connectionClosed(this);
}