diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2020-04-18 09:28:21 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-18 09:28:21 +0000 |
commit | 5d74a29e95bbfa9266b9c8661a025a4dd58e77a7 (patch) | |
tree | ac43095d7e35faabf1fffda5e4938180f1c3d44e | |
parent | 3841078baa7b1b80631f21e899fd47651564691c (diff) | |
parent | 81542c5cb6c4216ea6a8b17b0f16694f0f740e46 (diff) |
Merge "Make IpClientIntegrationTest pass on rvc-dev." into rvc-dev
-rw-r--r-- | tests/integration/src/android/net/ip/IpClientIntegrationTest.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java index 56ad6c1..fdeddca 100644 --- a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java +++ b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java @@ -407,7 +407,13 @@ public class IpClientIntegrationTest { mPacketReaderThread.start(); mHandler = mPacketReaderThread.getThreadHandler(); - mTapFd = iface.getFileDescriptor().getFileDescriptor(); + // Detach the FileDescriptor from the ParcelFileDescriptor. + // Otherwise, the garbage collector might call the ParcelFileDescriptor's finalizer, which + // closes the FileDescriptor and destroys our tap interface. An alternative would be to + // make the ParcelFileDescriptor or the TestNetworkInterface a class member so they never + // go out of scope. + mTapFd = new FileDescriptor(); + mTapFd.setInt$(iface.getFileDescriptor().detachFd()); mPacketReader = new TapPacketReader(mHandler, mTapFd, DATA_BUFFER_LEN); mHandler.post(() -> mPacketReader.start()); } |