summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-02-16 22:10:15 +0200
committerVaadin Code Review <review@vaadin.com>2015-02-17 07:12:51 +0000
commite2ddc9f9af3003d2e6d7282ad92a74dafc451b54 (patch)
treeff719a75601a9a7c0b3d930e3b1e7588d8485ef9 /server
parent1ff0de1892f1868c717e8334c96e9e0cb5ea9fd6 (diff)
downloadvaadin-framework-e2ddc9f9af3003d2e6d7282ad92a74dafc451b54.tar.gz
vaadin-framework-e2ddc9f9af3003d2e6d7282ad92a74dafc451b54.zip
Properly handle null in critical notifications (#16592)
Change-Id: I85994e47f99e2ac5431e67c56f432380e84af23d
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/VaadinService.java14
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServiceTest.java14
2 files changed, 26 insertions, 2 deletions
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 36d6910a7a..2aaab31dd1 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -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 {
diff --git a/server/tests/src/com/vaadin/server/VaadinServiceTest.java b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
index 51325067d2..c2ca8b0e57 100644
--- a/server/tests/src/com/vaadin/server/VaadinServiceTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
@@ -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);
+ }
+ }
+ }
+ }
+ }
}