diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-04-21 03:04:13 +0000 |
---|---|---|
committer | Mark Chien <markchien@google.com> | 2020-04-22 06:44:01 +0000 |
commit | 768d586ccfe0533008f7a15a6ce6925ce00f9dd6 (patch) | |
tree | a63442fd161096a04d8db7388008d2d11b9d592e | |
parent | af558386e7132f9cc5ae7e8f3e74a5db8bc928e2 (diff) |
Fix an issue in TrackRecord.
TrackRecord<T> implements List<T> but also has an add(T)
method which conflicts with List<T>#add as it has a different
return type. As nobody is using the return value of this now,
use the signature of List<T>#add to remove the problem.
Bug: 153613718
Test: NetworkStackTests FrameworksNetTests
Merged-In: Ie9eb4d7158e9583d4052e86f87062e3032b023e3
Change-Id: Ie9eb4d7158e9583d4052e86f87062e3032b023e3
-rw-r--r-- | tests/lib/multivariant/com/android/testutils/TrackRecord.kt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/lib/multivariant/com/android/testutils/TrackRecord.kt b/tests/lib/multivariant/com/android/testutils/TrackRecord.kt index 6f142dc..ab2dc64 100644 --- a/tests/lib/multivariant/com/android/testutils/TrackRecord.kt +++ b/tests/lib/multivariant/com/android/testutils/TrackRecord.kt @@ -27,9 +27,10 @@ import kotlin.concurrent.withLock */ interface TrackRecord<E> : List<E> { /** - * Adds an element to this queue, waking up threads waiting for one. Returns the element. + * Adds an element to this queue, waking up threads waiting for one. Returns true, as + * per the contract for List. */ - fun add(e: E): TrackRecord<E> + fun add(e: E): Boolean /** * Returns the first element after {@param pos}, possibly blocking until one is available, or @@ -91,12 +92,12 @@ class ArrayTrackRecord<E> : TrackRecord<E> { } // TrackRecord<E> implementation - override fun add(e: E): ArrayTrackRecord<E> { + override fun add(e: E): Boolean { lock.withLock { elements.add(e) condition.signalAll() } - return this + return true } override fun poll(timeoutMs: Long, pos: Int, predicate: (E) -> Boolean) = lock.withLock { elements.getOrNull(pollForIndexReadLocked(timeoutMs, pos, predicate)) |