Merge "Change throw to Log.wtf" into main am: ab2fd4cac9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2855567 Change-Id: I727e9d8ec9686fda2b1a35d62e9f810eb57134e4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
f5c44cfdea
2 changed files with 14 additions and 4 deletions
|
|
@ -171,7 +171,8 @@ public class RoutingCoordinatorService extends IRoutingCoordinator.Stub {
|
|||
}
|
||||
final ForwardingPair fwp = new ForwardingPair(fromIface, toIface);
|
||||
if (mForwardedInterfaces.contains(fwp)) {
|
||||
throw new IllegalStateException("Forward already exists between ifaces "
|
||||
// TODO: remove if no reports are observed from the below log
|
||||
Log.wtf(TAG, "Forward already exists between ifaces "
|
||||
+ fromIface + " → " + toIface);
|
||||
}
|
||||
mForwardedInterfaces.add(fwp);
|
||||
|
|
|
|||
|
|
@ -18,14 +18,17 @@ package com.android.server.connectivity
|
|||
|
||||
import android.net.INetd
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
|
||||
import com.android.testutils.DevSdkIgnoreRunner
|
||||
import com.android.testutils.tryTest
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers.any
|
||||
import org.mockito.Mockito.inOrder
|
||||
import org.mockito.Mockito.mock
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
@RunWith(DevSdkIgnoreRunner::class)
|
||||
@IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
|
||||
|
|
@ -46,9 +49,15 @@ class RoutingCoordinatorServiceTest {
|
|||
inOrder.verify(mNetd).tetherAddForward("from2", "to1")
|
||||
inOrder.verify(mNetd).ipfwdAddInterfaceForward("from2", "to1")
|
||||
|
||||
assertFailsWith<IllegalStateException> {
|
||||
// Can't add the same pair again
|
||||
val hasFailed = AtomicBoolean(false)
|
||||
val prevHandler = Log.setWtfHandler { tag, what, system ->
|
||||
hasFailed.set(true)
|
||||
}
|
||||
tryTest {
|
||||
mService.addInterfaceForward("from2", "to1")
|
||||
assertTrue(hasFailed.get())
|
||||
} cleanup {
|
||||
Log.setWtfHandler(prevHandler)
|
||||
}
|
||||
|
||||
mService.removeInterfaceForward("from1", "to1")
|
||||
|
|
|
|||
Loading…
Reference in a new issue