From b41e4f6326d3ca13ec0bd431261a6993face6351 Mon Sep 17 00:00:00 2001 From: Yuyang Huang Date: Tue, 11 Jun 2024 15:09:41 +0900 Subject: [PATCH] Add individual try/catch blocks for ParcelFileDescriptor closure Enclosed each ParcelFileDescriptor.close() call in its own try/catch block to ensure that if one closure throws an exception, the others will still be attempted. Bug: 346469095 Test: TH Change-Id: Ib59fffaa39488acb73bbdbe8ebc795043f2b301f --- .../server/connectivity/ClatCoordinator.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/service/src/com/android/server/connectivity/ClatCoordinator.java b/service/src/com/android/server/connectivity/ClatCoordinator.java index d886182731..f333dae572 100644 --- a/service/src/com/android/server/connectivity/ClatCoordinator.java +++ b/service/src/com/android/server/connectivity/ClatCoordinator.java @@ -683,13 +683,25 @@ public class ClatCoordinator { throw new IOException("Failed to start clat ", e); } finally { if (tunFd != null) { - tunFd.close(); + try { + tunFd.close(); + } catch (IOException e) { + Log.e(TAG, "Fail to close tun file descriptor " + e); + } } if (readSock6 != null) { - readSock6.close(); + try { + readSock6.close(); + } catch (IOException e) { + Log.e(TAG, "Fail to close read socket " + e); + } } if (writeSock6 != null) { - writeSock6.close(); + try { + writeSock6.close(); + } catch (IOException e) { + Log.e(TAG, "Fail to close write socket " + e); + } } } }