Skip to content

Commit 303fa22

Browse files
committed
Issue nostra13#725: Prevent NPE log
1 parent 4f0065f commit 303fa22

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

library/src/com/nostra13/universalimageloader/core/LoadAndDisplayImageTask.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ final class LoadAndDisplayImageTask implements Runnable, IoUtils.CopyListener {
6868
private static final String LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED = "ImageAware was collected by GC. Task is cancelled. [%s]";
6969
private static final String LOG_TASK_INTERRUPTED = "Task was interrupted [%s]";
7070

71+
private static final String ERROR_NO_IMAGE_STREAM = "No stream for image [%s]";
7172
private static final String ERROR_PRE_PROCESSOR_NULL = "Pre-processor returned null [%s]";
7273
private static final String ERROR_POST_PROCESSOR_NULL = "Post-processor returned null [%s]";
7374
private static final String ERROR_PROCESSOR_FOR_DISK_CACHE_NULL = "Bitmap processor for disk cache returned null [%s]";
@@ -288,10 +289,15 @@ private boolean tryCacheImageOnDisk() throws TaskCancelledException {
288289

289290
private boolean downloadImage() throws IOException {
290291
InputStream is = getDownloader().getStream(uri, options.getExtraForDownloader());
291-
try {
292-
return configuration.diskCache.save(uri, is, this);
293-
} finally {
294-
IoUtils.closeSilently(is);
292+
if (is == null) {
293+
L.e(ERROR_NO_IMAGE_STREAM, memoryCacheKey);
294+
return false;
295+
} else {
296+
try {
297+
return configuration.diskCache.save(uri, is, this);
298+
} finally {
299+
IoUtils.closeSilently(is);
300+
}
295301
}
296302
}
297303

0 commit comments

Comments
 (0)