From 994a99698126cc3f6945b1171f7aaccc3aeb1094 Mon Sep 17 00:00:00 2001 From: Jonas Konrad Date: Tue, 15 Apr 2014 11:56:43 +0200 Subject: [PATCH] Fix NPE while encoding when favicon was missing --- api/src/main/java/net/md_5/bungee/api/Favicon.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/Favicon.java b/api/src/main/java/net/md_5/bungee/api/Favicon.java index db405b4e..0c9ec07e 100644 --- a/api/src/main/java/net/md_5/bungee/api/Favicon.java +++ b/api/src/main/java/net/md_5/bungee/api/Favicon.java @@ -14,6 +14,7 @@ import java.io.InputStream; import javax.imageio.ImageIO; import lombok.AccessLevel; import lombok.Getter; +import lombok.NonNull; import lombok.RequiredArgsConstructor; /** @@ -28,13 +29,14 @@ public class Favicon @Override public void write(JsonWriter out, Favicon value) throws IOException { - TypeAdapters.STRING.write( out, value.getEncoded() ); + TypeAdapters.STRING.write( out, value == null ? null : value.getEncoded() ); } @Override public Favicon read(JsonReader in) throws IOException { - return create( TypeAdapters.STRING.read( in ) ); + String enc = TypeAdapters.STRING.read( in ); + return enc == null ? null : create( enc ); } }; @@ -46,6 +48,7 @@ public class Favicon /** * The base64 encoded favicon, including MIME header. */ + @NonNull @Getter private final String encoded;