]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Use try-with-resources for IO
authorMarkus Pfeiffer <markus.pfeiffer@relution.io>
Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Feb 2024 11:24:52 +0000 (12:24 +0100)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java

index 6bd5e6bc403badfa9b6b5303f09154cc08ad36db..5f5b2a1879e75731506abc97794a6f6313aa733f 100644 (file)
@@ -1037,9 +1037,8 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                        @Override
                        public synchronized void run()
                        {
-                               try
+                               try (FileInputStream plain = new FileInputStream(mFd.getFileDescriptor()))
                                {
-                                       FileInputStream plain = new FileInputStream(mFd.getFileDescriptor());
                                        ByteBuffer packet = ByteBuffer.allocate(mCache.mMtu);
                                        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 */
                                }