Make QualifiedResourceFetchProducer nullsafe
@@ -9,9 +9,11 @@ package com.facebook.imagepipeline.producers;
import android.content.ContentResolver;
import android.net.Uri;
+import com.facebook.common.internal.Preconditions;
import com.facebook.common.memory.PooledByteBufferFactory;
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.request.ImageRequest;
+import com.facebook.infer.annotation.Nullsafe;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.Executor;
@@ -20,6 +22,7 @@ import java.util.concurrent.Executor;
* The {@link QualifiedResourceFetchProducer} uses the {@link ContentResolver} to allow fetching
* resources that might not be part of the application's package.
*/
+@Nullsafe(Nullsafe.Mode.LOCAL)
public class QualifiedResourceFetchProducer extends LocalFetchProducer {
public static final String PRODUCER_NAME = "QualifiedResourceFetchProducer";
@@ -38,6 +41,7 @@ public class QualifiedResourceFetchProducer extends LocalFetchProducer {
protected EncodedImage getEncodedImage(final ImageRequest imageRequest) throws IOException {
final Uri uri = imageRequest.getSourceUri();
final InputStream inputStream = mContentResolver.openInputStream(uri);
+ Preconditions.checkNotNull(inputStream, "ContentResolver returned null InputStream");
return getEncodedImage(inputStream, EncodedImage.UNKNOWN_STREAM_SIZE);
}
