diff options
author | Josh Gao <jmgao@google.com> | 2018-10-31 12:26:40 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-11-09 14:10:40 -0800 |
commit | 42bd8e1ec05dd11a7838ff37345ff1d6be77641b (patch) | |
tree | e12772f4b5447f9f6517967634645b586a857a85 /tests/net/java/com/android/server/IpSecServiceTest.java | |
parent | 401fb2485aac4ecf44921706a3476f0fcaedc035 (diff) |
Avoid calling ParcelFileDescriptor.fromSocket on new Sockets.
Previously, we were calling ParcelFileDescriptor.fromSocket on a newly
initialized Socket, which doesn't actually create a file descriptor
until the Socket is bound or connected.
Bind the Socket to a random port to force the file descriptor to be
allocated.
Test: treehugger
Change-Id: Id92a3e1316881d1c5382485aa2d6a41fc37e9651
Diffstat (limited to 'tests/net/java/com/android/server/IpSecServiceTest.java')
-rw-r--r-- | tests/net/java/com/android/server/IpSecServiceTest.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/net/java/com/android/server/IpSecServiceTest.java b/tests/net/java/com/android/server/IpSecServiceTest.java index 2c94a601fbf6..8124f0aabcb9 100644 --- a/tests/net/java/com/android/server/IpSecServiceTest.java +++ b/tests/net/java/com/android/server/IpSecServiceTest.java @@ -422,7 +422,9 @@ public class IpSecServiceTest { @Test public void testRemoveTransportModeTransform() throws Exception { - ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket()); + Socket socket = new Socket(); + socket.bind(null); + ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket); mIpSecService.removeTransportModeTransforms(pfd); verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd.getFileDescriptor()); |