Throw IllegalStateException when inserting an existing item
This commit throws IllegalStateException instead of IllegalArgumentException when inserting an existing item to TestBpfMap to fit the current behavior in the production code. This is safe given that this is only for test and no one is currently check the exception. Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest Bug: 354619988 Change-Id: I1e5c6e99a0d95b44dd556de8805bb16c3d1a4f61
This commit is contained in:
parent
c694c351c0
commit
c1856de66e
1 changed files with 4 additions and 3 deletions
|
|
@ -65,10 +65,11 @@ public class TestBpfMap<K extends Struct, V extends Struct> implements IBpfMap<K
|
|||
|
||||
@Override
|
||||
public void insertEntry(K key, V value) throws ErrnoException,
|
||||
IllegalArgumentException {
|
||||
// The entry is created if and only if it doesn't exist. See BpfMap#insertEntry.
|
||||
IllegalStateException {
|
||||
// The entry is created if and only if it doesn't exist.
|
||||
// And throws exception if it exists. See BpfMap#insertEntry.
|
||||
if (mMap.get(key) != null) {
|
||||
throw new IllegalArgumentException(key + " already exist");
|
||||
throw new IllegalStateException(key + " already exist");
|
||||
}
|
||||
mMap.put(key, value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue