android: Use try-with-resources for IO
This commit is contained in:
committed by
Tobias Brunner
parent
73af77709a
commit
b687f0c22f
+2
-3
@@ -1037,9 +1037,8 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void run()
|
public synchronized void run()
|
||||||
{
|
{
|
||||||
try
|
try (FileInputStream plain = new FileInputStream(mFd.getFileDescriptor()))
|
||||||
{
|
{
|
||||||
FileInputStream plain = new FileInputStream(mFd.getFileDescriptor());
|
|
||||||
ByteBuffer packet = ByteBuffer.allocate(mCache.mMtu);
|
ByteBuffer packet = ByteBuffer.allocate(mCache.mMtu);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@@ -1073,7 +1072,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ClosedByInterruptException | InterruptedException e)
|
catch (final ClosedByInterruptException | InterruptedException e)
|
||||||
{
|
{
|
||||||
/* regular interruption */
|
/* regular interruption */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user