]> source.dussan.org Git - vaadin-framework.git/commitdiff
Properly handle null in critical notifications (#16592)
authorArtur Signell <artur@vaadin.com>
Mon, 16 Feb 2015 20:10:15 +0000 (22:10 +0200)
committerArtur Signell <artur@vaadin.com>
Thu, 19 Feb 2015 11:06:46 +0000 (13:06 +0200)
Change-Id: I85994e47f99e2ac5431e67c56f432380e84af23d

server/src/com/vaadin/server/VaadinService.java
server/tests/src/com/vaadin/server/VaadinServiceTest.java

index 36d6910a7a43f223d1f2cd630638d6881fc9224a..2aaab31dd1afdaf96180b7dd3bd0379628b1a74e 100644 (file)
@@ -1581,8 +1581,18 @@ public abstract class VaadinService implements Serializable {
             }
 
             JsonObject appError = Json.createObject();
-            appError.put("caption", caption);
-            appError.put("message", message);
+            if (caption == null) {
+                appError.put("caption", Json.createNull());
+            } else {
+                appError.put("caption", caption);
+            }
+
+            if (message == null) {
+                appError.put("message", Json.createNull());
+            } else {
+                appError.put("message", message);
+            }
+
             if (url == null) {
                 appError.put("url", Json.createNull());
             } else {
index 51325067d24cbc17a5b56c972ee6b0ce6bdc5bae..c2ca8b0e5703adb560d32978aa703d435bef20ec 100644 (file)
@@ -66,4 +66,18 @@ public class VaadinServiceTest {
         Assert.assertEquals("SessionDestroyListeners not called exactly once",
                 1, listener.callCount);
     }
+
+    @Test
+    public void testCriticalNotificationNullHandling() {
+        for (String caption : new String[] { "some caption", null }) {
+            for (String message : new String[] { "some message", null }) {
+                for (String details : new String[] { "some details", null }) {
+                    for (String url : new String[] { "some url", null }) {
+                        VaadinService.createCriticalNotificationJSON(caption,
+                                message, details, url);
+                    }
+                }
+            }
+        }
+    }
 }