diff options
author | Artem Godin <artem@vaadin.com> | 2013-10-03 15:47:08 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-10-04 10:45:47 +0000 |
commit | 503e5757bbac1a28c8987ecae9f75d271a61899b (patch) | |
tree | a875a29e57218fb41bd20525d11b72456d4629c5 | |
parent | 633b4e858c31769f4b8848c934651da1d54b2721 (diff) | |
download | vaadin-framework-503e5757bbac1a28c8987ecae9f75d271a61899b.tar.gz vaadin-framework-503e5757bbac1a28c8987ecae9f75d271a61899b.zip |
Fix NullPointerException in logger when message is null (#12588)
LogSection.publish and VConsole.log/VConsole.error methods now replace
null message with an empty string ("")
Change-Id: I735b51bce971ababe2557f1b6c317c01066bc03c
-rw-r--r-- | client/src/com/vaadin/client/VConsole.java | 18 | ||||
-rw-r--r-- | client/src/com/vaadin/client/debug/internal/LogSection.java | 6 |
2 files changed, 20 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/VConsole.java b/client/src/com/vaadin/client/VConsole.java index 37ed8e6370..32eb206a70 100644 --- a/client/src/com/vaadin/client/VConsole.java +++ b/client/src/com/vaadin/client/VConsole.java @@ -41,25 +41,35 @@ public class VConsole { public static void log(String msg) { if (LogConfiguration.loggingIsEnabled(Level.INFO)) { - getLogger().log(Level.INFO, msg); + // Check for null, so no NullPointerException is generated when + // formatting (#12588) + getLogger().log(Level.INFO, msg == null ? "null" : msg); } } public static void log(Throwable e) { if (LogConfiguration.loggingIsEnabled(Level.INFO)) { - getLogger().log(Level.INFO, e.getMessage(), e); + // Check for null, so no NullPointerException is generated when + // formatting (#12588) + getLogger().log(Level.INFO, + e.getMessage() == null ? "" : e.getMessage(), e); } } public static void error(Throwable e) { if (LogConfiguration.loggingIsEnabled(Level.SEVERE)) { - getLogger().log(Level.SEVERE, e.getMessage(), e); + // Check for null, so no NullPointerException is generated when + // formatting (#12588) + getLogger().log(Level.SEVERE, + e.getMessage() == null ? "" : e.getMessage(), e); } } public static void error(String msg) { if (LogConfiguration.loggingIsEnabled(Level.SEVERE)) { - getLogger().log(Level.SEVERE, msg); + // Check for null, so no NullPointerException is generated when + // formatting (#12588) + getLogger().log(Level.SEVERE, msg == null ? "null" : msg); } } diff --git a/client/src/com/vaadin/client/debug/internal/LogSection.java b/client/src/com/vaadin/client/debug/internal/LogSection.java index 1e7524b56d..f792ec95be 100644 --- a/client/src/com/vaadin/client/debug/internal/LogSection.java +++ b/client/src/com/vaadin/client/debug/internal/LogSection.java @@ -73,6 +73,12 @@ public class LogSection implements Section { return; } + // If no message is provided, record.getMessage will be null and so + // the formatter.format will fail with NullPointerException (#12588) + if (record.getMessage() == null) { + record.setMessage(""); + } + Formatter formatter = getFormatter(); String msg = formatter.format(record); |