From 405e0a66a96f38ddb94fe9aaf35669fde0d22abd Mon Sep 17 00:00:00 2001 From: Eve Matthaey Date: Fri, 3 Nov 2023 16:54:54 -0700 Subject: [PATCH] Fix NPE due to parameter made non-nullable during conversion Differential Revision: D50982505 fbshipit-source-id: d4875d50628366f371cf3429975c6a7f66123b3a --- .../facebook/imagepipeline/core/ImagePipeline.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ImagePipeline.java b/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ImagePipeline.java index 0e4b2ca3b8..d773716665 100644 --- a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ImagePipeline.java +++ b/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ImagePipeline.java @@ -447,12 +447,12 @@ public DataSource> fetchEncodedImage( * @return a DataSource that can safely be ignored. */ public DataSource prefetchToBitmapCache( - ImageRequest imageRequest, @Nullable Object callerContext) { + @Nullable ImageRequest imageRequest, @Nullable Object callerContext) { return prefetchToBitmapCache(imageRequest, callerContext, null); } public DataSource prefetchToBitmapCache( - ImageRequest imageRequest, + @Nullable ImageRequest imageRequest, @Nullable Object callerContext, @Nullable RequestListener requestListener) { try { @@ -469,6 +469,7 @@ public DataSource prefetchToBitmapCache( && isInBitmapMemoryCache(imageRequest)) { return DataSources.immediateSuccessfulDataSource(); } + Preconditions.checkNotNull(imageRequest); final Boolean shouldDecodePrefetches = imageRequest.shouldDecodePrefetches(); final boolean skipBitmapCache = shouldDecodePrefetches != null @@ -722,7 +723,7 @@ public void clearCaches() { * @param uri the uri for the image to be looked up. * @return true if the image was found in the bitmap memory cache, false otherwise */ - public boolean isInBitmapMemoryCache(final Uri uri) { + public boolean isInBitmapMemoryCache(@Nullable final Uri uri) { if (uri == null) { return false; } @@ -741,7 +742,7 @@ public MemoryCache getBitmapMemoryCache() { * @param imageRequest the imageRequest for the image to be looked up. * @return true if the image was found in the bitmap memory cache, false otherwise. */ - public boolean isInBitmapMemoryCache(final ImageRequest imageRequest) { + public boolean isInBitmapMemoryCache(@Nullable final ImageRequest imageRequest) { if (imageRequest == null) { return false; } @@ -760,7 +761,7 @@ public boolean isInBitmapMemoryCache(final ImageRequest imageRequest) { * @param uri the uri for the image to be looked up. * @return true if the image was found in the encoded memory cache, false otherwise */ - public boolean isInEncodedMemoryCache(final Uri uri) { + public boolean isInEncodedMemoryCache(@Nullable final Uri uri) { if (uri == null) { return false; } @@ -774,7 +775,7 @@ public boolean isInEncodedMemoryCache(final Uri uri) { * @param imageRequest the imageRequest for the image to be looked up. * @return true if the image was found in the encoded memory cache, false otherwise. */ - public boolean isInEncodedMemoryCache(final ImageRequest imageRequest) { + public boolean isInEncodedMemoryCache(@Nullable final ImageRequest imageRequest) { if (imageRequest == null) { return false; }