From 107d6b011db98e549b401ae56daa01d2701ad287 Mon Sep 17 00:00:00 2001 From: xxyy Date: Sun, 25 May 2014 18:10:42 +0200 Subject: [PATCH] Fix ServerPing NPE w/ String favicons Currently, passing a null favicon String to the ServerPing(Protocol, Players, String, String) constructor causes a NPE. However, passing a null `Favicon` object to the corresponding constructor does not cause one. Setting the favicon String using the setFavicon(String) method doesn't cause a NPE either. Therefore, the NPE thrown by the constructor is inconsistent and should be avoided. Please find a sample NPE here: http://newpaste.md-5.net/pmtqjc8vl (Note the `null` favicon) This PR changes the documented (unintended?) behaviour by adding a null check before passing the favicon String to the alternative `Favicon` object constructor. This makes the constructor consistent with the other one and the `setFavicon(String)` method. This also adds compatibility for old (made before Favicon API) plugins passing `null` favicon Strings (and expecting no favicon to be displayed instead of a NPE). Thanks! --- api/src/main/java/net/md_5/bungee/api/ServerPing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/ServerPing.java b/api/src/main/java/net/md_5/bungee/api/ServerPing.java index 9fe4fffee..87dfa1729 100644 --- a/api/src/main/java/net/md_5/bungee/api/ServerPing.java +++ b/api/src/main/java/net/md_5/bungee/api/ServerPing.java @@ -77,7 +77,7 @@ public class ServerPing @Deprecated public ServerPing(Protocol version, Players players, String description, String favicon) { - this( version, players, description, Favicon.create( favicon ) ); + this( version, players, description, favicon == null ? null : Favicon.create( favicon ) ); } @Deprecated