You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by th...@apache.org on 2014/06/22 22:48:49 UTC

git commit: Some adjustments for TAP5-2230

Repository: tapestry-5
Updated Branches:
  refs/heads/master 2c3361119 -> fbd7d031e


Some adjustments for TAP5-2230


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/fbd7d031
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/fbd7d031
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/fbd7d031

Branch: refs/heads/master
Commit: fbd7d031e2753411c540dd00d2c3c8d8753dd89c
Parents: 2c33611
Author: Thiago H. de Paula Figueiredo <th...@apache.org>
Authored: Sun Jun 22 17:48:29 2014 -0300
Committer: Thiago H. de Paula Figueiredo <th...@apache.org>
Committed: Sun Jun 22 17:48:29 2014 -0300

----------------------------------------------------------------------
 .../services/ajax/AjaxResponseRendererImpl.java | 13 ++++++++--
 .../org/apache/tapestry5/json/JSONObject.java   |  7 +----
 .../test/groovy/json/specs/JSONArraySpec.groovy | 27 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fbd7d031/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxResponseRendererImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxResponseRendererImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxResponseRendererImpl.java
index 6d3b329..b263f7c 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxResponseRendererImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxResponseRendererImpl.java
@@ -1,4 +1,4 @@
-//  Copyright 2011, 2013 The Apache Software Foundation
+//  Copyright 2011, 2013, 2014 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -63,7 +63,16 @@ public class AjaxResponseRendererImpl implements AjaxResponseRenderer
     {
         assert zone != null;
 
-        addRender(zone.getClientId(), zone.getBody());
+        final String clientId = zone.getClientId();
+        
+        if (clientId == null)
+        {
+            throw new IllegalArgumentException(
+                    "Attempt to render a ClientBodyElement, probably a Zone, with a null clientId. "
+                    + "You can solve this by using the id parameter.");
+        }
+        
+        addRender(clientId, zone.getBody());
 
         return this;
     }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fbd7d031/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONObject.java b/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONObject.java
index 651260b..7c5ccb4 100644
--- a/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONObject.java
+++ b/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONObject.java
@@ -793,7 +793,7 @@ public final class JSONObject extends JSONCollection
     static void testValidity(Object value)
     {
         if (value == null)
-            return;
+            throw new IllegalArgumentException("null isn't valid in JSONObject and JSONArray. Use JSONObject.NULL instead.");
 
         boolean found = false;
         Class actual = value.getClass();
@@ -914,11 +914,6 @@ public final class JSONObject extends JSONCollection
     static void printValue(JSONPrintSession session, Object value)
     {
     	
-    	// TAP5-2342: a little more robustness by treating null as JSONObject.NULL and avoinding an NPE.
-    	if (value == null) {
-    		value = NULL;
-    	}
-    	
         if (value instanceof JSONObject)
         {
             ((JSONObject) value).print(session);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fbd7d031/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy b/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy
index 24066c9..7cbab1b 100644
--- a/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy
+++ b/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy
@@ -341,5 +341,32 @@ class JSONArraySpec extends Specification {
 
         list.toString(true) == "[1,2,3]"
     }
+	
+	def "put() should throw an IllegalArgumentException when receiving null"() {
+		
+		def array = new JSONArray()
+		
+		when:
+		
+		array.put(null)
+		
+		then:
+		
+		thrown IllegalArgumentException
+		
+	}
+	
+	def "new JSONArray() should throw an IllegalArgumentException when receiving null"() {
+		
+		when:
+		
+		new JSONArray(1, null, 3)
+		
+		then:
+		
+		thrown IllegalArgumentException
+		
+	}
+
 
 }