diff options
author | 2025-02-13 15:59:15 -0800 | |
---|---|---|
committer | 2025-02-13 16:00:24 -0800 | |
commit | 55cf6ca51669c2168a81082ee758fd66740f1b88 (patch) | |
tree | 28c2a8e223ee98980568536e0e5449000e0ffd4f | |
parent | 7e906340128f3f517c4c580db0374a32816e723d (diff) |
Errorprone fix & enforce ThreadJoinLoop
Bug: 311772251
Test: m BluetoothInstrumentationTests
Flag: TEST_ONLY
Change-Id: I9b6b3a59133520d485909cd4dedb6e6f189863d5
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | android/app/tests/unit/src/com/android/bluetooth/TestLooper.java | 8 |
2 files changed, 4 insertions, 5 deletions
diff --git a/Android.bp b/Android.bp index bef6c85049..d23d8552d7 100644 --- a/Android.bp +++ b/Android.bp @@ -167,6 +167,7 @@ java_defaults { "-Xep:StringCaseLocaleUsage:ERROR", "-Xep:StringCharset:ERROR", "-Xep:SynchronizeOnNonFinalField:ERROR", + "-Xep:ThreadJoinLoop:ERROR", "-Xep:ToStringReturnsNull:ERROR", "-Xep:TruthConstantAsserts:ERROR", "-Xep:TruthIncompatibleType:ERROR", diff --git a/android/app/tests/unit/src/com/android/bluetooth/TestLooper.java b/android/app/tests/unit/src/com/android/bluetooth/TestLooper.java index 31f4515578..ae64352e37 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/TestLooper.java +++ b/android/app/tests/unit/src/com/android/bluetooth/TestLooper.java @@ -27,6 +27,8 @@ import android.util.Log; import com.android.modules.utils.HandlerExecutor; +import com.google.common.util.concurrent.Uninterruptibles; + import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -298,11 +300,7 @@ public class TestLooper { if (mAutoDispatchThread.isAlive()) { mAutoDispatchThread.interrupt(); } - try { - mAutoDispatchThread.join(); - } catch (InterruptedException e) { - // Catch exception from join. - } + Uninterruptibles.joinUninterruptibly(mAutoDispatchThread); RuntimeException e = mAutoDispatchThread.getException(); mAutoDispatchThread = null; |