Add Thread.currentThread().interrupt() for InterruptedExceptions.

PiperOrigin-RevId: 549975878
This commit is contained in:
huangdarwin 2023-07-21 17:59:07 +01:00 committed by Rohit Singh
parent 5858723a06
commit d7b5ab9f23
9 changed files with 23 additions and 6 deletions

View File

@ -112,6 +112,7 @@ public final class DefaultVideoFrameProcessorVideoFrameRenderingTest {
// to swap buffers, to avoid this behavior. // to swap buffers, to avoid this behavior.
Thread.sleep(PER_FRAME_RENDERING_WAIT_TIME_MS); Thread.sleep(PER_FRAME_RENDERING_WAIT_TIME_MS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
}, },
@ -228,6 +229,7 @@ public final class DefaultVideoFrameProcessorVideoFrameRenderingTest {
// to swap buffers, to avoid this behavior. // to swap buffers, to avoid this behavior.
Thread.sleep(PER_FRAME_RENDERING_WAIT_TIME_MS); Thread.sleep(PER_FRAME_RENDERING_WAIT_TIME_MS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
}, },

View File

@ -146,7 +146,10 @@ public abstract class BitmapOverlay extends TextureOverlay {
ListenableFuture<Bitmap> future = bitmapLoader.loadBitmap(overlayBitmapUri); ListenableFuture<Bitmap> future = bitmapLoader.loadBitmap(overlayBitmapUri);
try { try {
lastBitmap = future.get(); lastBitmap = future.get();
} catch (ExecutionException | InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new VideoFrameProcessingException(e);
} catch (ExecutionException e) {
throw new VideoFrameProcessingException(e); throw new VideoFrameProcessingException(e);
} }
} }

View File

@ -202,10 +202,13 @@ public class TransformerAndroidTestRunner {
throw exportTestResult.analysisException; throw exportTestResult.analysisException;
} }
return exportTestResult; return exportTestResult;
} catch (InterruptedException } catch (InterruptedException e) {
| IOException Thread.currentThread().interrupt();
| TimeoutException resultJson.put(
| UnsupportedOperationException e) { "exportResult",
new JSONObject().put("testException", AndroidTestUtil.exceptionAsJsonObject(e)));
throw e;
} catch (IOException | TimeoutException | UnsupportedOperationException e) {
resultJson.put( resultJson.put(
"exportResult", "exportResult",
new JSONObject().put("testException", AndroidTestUtil.exceptionAsJsonObject(e))); new JSONObject().put("testException", AndroidTestUtil.exceptionAsJsonObject(e)));
@ -404,6 +407,7 @@ public class TransformerAndroidTestRunner {
/* distortedVideoPath= */ outputVideoFile.getPath()); /* distortedVideoPath= */ outputVideoFile.getPath());
testResultBuilder.setSsim(ssim); testResultBuilder.setSsim(ssim);
} catch (InterruptedException interruptedException) { } catch (InterruptedException interruptedException) {
Thread.currentThread().interrupt();
// InterruptedException is a special unexpected case because it is not related to Ssim // InterruptedException is a special unexpected case because it is not related to Ssim
// calculation, so it should be thrown, rather than processed as part of the // calculation, so it should be thrown, rather than processed as part of the
// ExportTestResult. // ExportTestResult.

View File

@ -558,6 +558,7 @@ public final class DefaultVideoFrameProcessorTextureOutputPixelTest {
try { try {
videoFrameProcessorTestRunner.endFrameProcessing(VIDEO_FRAME_PROCESSING_WAIT_MS / 2); videoFrameProcessorTestRunner.endFrameProcessing(VIDEO_FRAME_PROCESSING_WAIT_MS / 2);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new VideoFrameProcessingException(e); throw new VideoFrameProcessingException(e);
} }
releaseOutputTextureCallback.release(presentationTimeUs); releaseOutputTextureCallback.release(presentationTimeUs);

View File

@ -46,7 +46,10 @@ import java.util.concurrent.ExecutionException;
trackGroupArray = trackGroupArray =
MetadataRetriever.retrieveMetadata(context, MediaItem.fromUri("file://" + filePath)) MetadataRetriever.retrieveMetadata(context, MediaItem.fromUri("file://" + filePath))
.get(); .get();
} catch (ExecutionException | InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
} catch (ExecutionException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }

View File

@ -116,6 +116,7 @@ public class ExoPlayerAssetLoaderTest {
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
exceptionRef.set(e); exceptionRef.set(e);
} }
} }

View File

@ -94,6 +94,7 @@ public class ImageAssetLoaderTest {
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
exceptionRef.set(e); exceptionRef.set(e);
} }
} }

View File

@ -1239,6 +1239,7 @@ public final class MediaItemExportTest {
try { try {
Thread.sleep(delayBetweenReadsMs); Thread.sleep(delayBetweenReadsMs);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
return extractor.read(input, seekPosition); return extractor.read(input, seekPosition);

View File

@ -95,6 +95,7 @@ public class TextureAssetLoaderTest {
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
exceptionRef.set(e); exceptionRef.set(e);
} }
} }