From 1b28d2c2fe29381e4708a0b718eee8511183e18e Mon Sep 17 00:00:00 2001 From: Evan Harris Date: Mon, 16 Sep 2019 13:57:04 -0500 Subject: [PATCH] Handle nulls when processing cover art better This expands on commit d4487a07a0fcacea1544d61c79a380f2e9bf3087. Signed-off-by: Andrew DeMaria --- .../player/controller/CoverArtController.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/CoverArtController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/CoverArtController.java index b3f0e0a9..f01678f1 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/CoverArtController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/CoverArtController.java @@ -380,13 +380,22 @@ public class CoverArtController implements LastModified { public BufferedImage createImage(int size) { if (coverArt != null) { InputStream in = null; + String reason = null; try { in = getImageInputStream(coverArt); - BufferedImage bimg = ImageIO.read(in); - if (bimg != null) { - return scale(bimg, size, size); + if (in == null) { + reason = "getImageInputStream"; } - LOG.warn("Failed to process cover art " + coverArt + ": {}", bimg); + else { + BufferedImage bimg = ImageIO.read(in); + if (bimg == null) { + reason = "ImageIO.read"; + } + else { + return scale(bimg, size, size); + } + } + LOG.warn("Failed to process cover art " + coverArt + ": " + reason + " failed"); } catch (Throwable x) { LOG.warn("Failed to process cover art " + coverArt + ": " + x, x); } finally {