diff --git a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer.java b/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer.java index 27fd68341a..0873f74b0c 100644 --- a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer.java +++ b/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer.java @@ -9,16 +9,16 @@ package com.facebook.imagepipeline.producers; +import javax.annotation.Nullable; + import java.io.File; import java.io.IOException; import java.util.Map; import java.util.concurrent.Executor; import android.content.ContentResolver; -import android.database.Cursor; import android.media.ExifInterface; import android.net.Uri; -import android.provider.MediaStore; import android.util.Pair; import com.facebook.common.internal.ImmutableMap; @@ -130,10 +130,14 @@ public void onCancellationRequested() { mExecutor.execute(cancellableProducerRunnable); } - @VisibleForTesting ExifInterface getExifInterface(Uri uri) throws IOException { + @VisibleForTesting @Nullable ExifInterface getExifInterface(Uri uri) { final String realPath = UriUtil.getRealPathFromUri(mContentResolver, uri); - if (canReadAsFile(realPath)) { + try { + if (canReadAsFile(realPath)) { return new ExifInterface(realPath); + } + } catch (IOException e) { + // If we cannot get the exif interface, return null as there is no thumbnail available } return null; } diff --git a/imagepipeline/src/test/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducerTest.java b/imagepipeline/src/test/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducerTest.java index 2b39c39d90..b8be062524 100644 --- a/imagepipeline/src/test/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducerTest.java +++ b/imagepipeline/src/test/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducerTest.java @@ -148,7 +148,7 @@ private TestLocalExifThumbnailProducer( } @Override - ExifInterface getExifInterface(Uri uri) throws IOException { + ExifInterface getExifInterface(Uri uri) { if (uri.equals(mUri)) { return mExifInterface; }