From d9776e74c8c022d200cca7cb8d1fcb5b16f07511 Mon Sep 17 00:00:00 2001 From: kimvde Date: Wed, 8 Jan 2025 08:00:16 -0800 Subject: [PATCH] PlayerListener: do not swallow exceptions thrown before waiting If an error occurred in the player before the test was calling one of the waitUntilSomething() methods, a timeout exception was thrown instead of the actual error. PiperOrigin-RevId: 713292292 --- .../androidx/media3/transformer/PlayerTestListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/PlayerTestListener.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/PlayerTestListener.java index 9d944fb5f8..57bcafb2d5 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/PlayerTestListener.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/PlayerTestListener.java @@ -130,9 +130,15 @@ public final class PlayerTestListener implements Player.Listener, AnalyticsListe private void waitOrThrow(ConditionVariable conditionVariable) throws TimeoutException, PlaybackException { - if (!conditionVariable.block(testTimeoutMs)) { + maybeThrowPlaybackException(); + boolean conditionVariableTimedOut = !conditionVariable.block(testTimeoutMs); + maybeThrowPlaybackException(); + if (conditionVariableTimedOut) { throw new TimeoutException(); } + } + + private void maybeThrowPlaybackException() throws PlaybackException { @Nullable PlaybackException playbackException = this.playbackException.get(); if (playbackException != null) { throw playbackException;