Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev

This commit is contained in:
Benedict Wong
2019-04-10 17:07:02 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 5 deletions

View File

@@ -208,6 +208,7 @@ public class IpSecService extends IIpSecService.Stub {
mBinder.linkToDeath(this, 0);
} catch (RemoteException e) {
binderDied();
e.rethrowFromSystemServer();
}
}
}

View File

@@ -18,6 +18,7 @@ package com.android.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq;
@@ -134,11 +135,11 @@ public class IpSecServiceRefcountedResourceTest {
IBinder binderMock = mock(IBinder.class);
doThrow(new RemoteException()).when(binderMock).linkToDeath(anyObject(), anyInt());
RefcountedResource<IResource> refcountedResource = getTestRefcountedResource(binderMock);
// Verify that cleanup is performed (Spy limitations prevent verification of method calls
// for binder death scenario; check refcount to determine if cleanup was performed.)
assertEquals(-1, refcountedResource.mRefCount);
try {
getTestRefcountedResource(binderMock);
fail("Expected exception to propogate when binder fails to link to death");
} catch (RuntimeException expected) {
}
}
@Test