From 7954537f5db66786a238b6199bb39bef51365687 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 10 Feb 2012 13:14:05 +0000 Subject: [PATCH] Fixing a loop condition when trying to print a Properties object which is null --- .../java/com/google/gwt/query/client/Properties.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java index 398960e3..c3502e34 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java @@ -137,8 +137,11 @@ public class Properties extends JavaScriptObject { } public final String toJsonString() { - String ret = ""; + // In dev-mode a null object casted to JavascriptObject does not throw a NPE + // e.g: System.out.println(((Properties)null).toJsonString()); + if (this == null) return "null"; + String ret = ""; for (String k : keys()){ String ky = k.matches("\\d+") ? k : "\"" + k + "\""; JsCache o = getArray(k).cast(); @@ -154,6 +157,7 @@ public class Properties extends JavaScriptObject { } ret += "],"; } else { + System.out.println("N"); Properties p = getJavaScriptObject(k); if (p != null) { ret += ky + ":" + p.toJsonString() + ","; @@ -168,6 +172,9 @@ public class Properties extends JavaScriptObject { } public final String toQueryString() { + // In dev-mode a null object casted to JavascriptObject does not throw a NPE + if (this == null) return "null"; + String ret = ""; for (String k : keys()) { ret += ret.isEmpty() ? "" : "&"; -- 2.39.5