From e979db777843ade4035860f7d81f8180214adc53 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 13 Dec 2018 19:44:59 -0500 Subject: [PATCH] Fix some unfriendly behavior in Favicon#create(Path) --- .../main/java/com/velocitypowered/api/util/Favicon.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/util/Favicon.java b/api/src/main/java/com/velocitypowered/api/util/Favicon.java index 276ad13d..a3ce2816 100644 --- a/api/src/main/java/com/velocitypowered/api/util/Favicon.java +++ b/api/src/main/java/com/velocitypowered/api/util/Favicon.java @@ -73,7 +73,7 @@ public final class Favicon { public static Favicon create(BufferedImage image) { Preconditions.checkNotNull(image, "image"); Preconditions.checkArgument(image.getWidth() == 64 && image.getHeight() == 64, - "Image is not 64x64(found %sx%s)", image.getWidth(), image.getHeight()); + "Image is not 64x64 (found %sx%s)", image.getWidth(),image.getHeight()); ByteArrayOutputStream os = new ByteArrayOutputStream(); try { ImageIO.write(image, "PNG", os); @@ -93,7 +93,11 @@ public final class Favicon { */ public static Favicon create(Path path) throws IOException { try (InputStream stream = Files.newInputStream(path)) { - return create(ImageIO.read(stream)); + BufferedImage image = ImageIO.read(stream); + if (image == null) { + throw new IOException("Unable to read the image."); + } + return create(image); } } }