From: Manolo Carrasco Date: Fri, 10 Feb 2012 13:14:05 +0000 (+0000) Subject: Fixing a loop condition when trying to print a Properties object which is null X-Git-Tag: release-1.3.2~121 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7954537f5db66786a238b6199bb39bef51365687;p=gwtquery.git Fixing a loop condition when trying to print a Properties object which is null --- 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() ? "" : "&";