Help with bug report

2013-04-16 Thread Tony Nelson
I ran into a problem with JSONArray today that I think deserves a bug report, 
but I'm not exactly sure what the correct/expected behavior should be, so I'm 
not sure how to file the bug.

This test case demonstrates the issue:

def test add null to array() {
setup:
String n = null
JSONArray obj = new JSONArray()
obj.put(n)

when:
String result = obj.toString()

then:
[] == result
}


I think I might expect the actual result to be [ null ], but you don't get that 
either, what you do get is a NULL pointer exception.

java.lang.NullPointerException
at org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:887)
at org.apache.tapestry5.json.JSONArray.print(JSONArray.java:436)
at 
org.apache.tapestry5.json.JSONCollection.toString(JSONCollection.java:47)
at com.starpoint.business.BusLogic1Test.test print empty 
array(BusLogic1Test.groovy:35)

Looking at the code, it would appear that you don't want null to be a valid 
value (though I would argue it's perfectly fine),

public JSONArray put(Object value)
{
assert value != null;

JSONObject.testValidity(value);

list.add(value);

return this;
}


I don't run with assertions enabled (who does??), but apparently 
JSONObject.testValidity passes just fine. You don't run into a problem until 
you actually try to print the array (or return it as an ajax response).

What is the correct behavior?
Tony

Since 1982, Starpoint Solutions has been a trusted source of human capital and 
solutions. We are committed to our clients, employees, environment, community 
and social concerns.  We foster an inclusive culture based on trust, respect, 
honesty and solid performance. Learn more about Starpoint and our social 
responsibility at http://www.starpoint.com/social_responsibility

This email message from Starpoint Solutions LLC is for the sole use of  the 
intended recipient(s) and may contain confidential and privileged  information. 
 Any unauthorized review, use, disclosure or distribution is prohibited.  If 
you are not the intended recipient, please contact the sender by reply email 
and destroy all copies of the original message.  Opinions, conclusions and 
other information in this message that do not relate to the official business 
of Starpoint Solutions shall be understood as neither given nor endorsed by it.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Help with bug report

2013-04-16 Thread Howard Lewis Ship
Obviously it would blow up if you ran with -ea

The docs specify the acceptable values for put().

You don't use a null, you use JSONObject.NULL.

I can't remember why it is done this way; it may have simply been done that
way in the original JSON.org source that the Tapestry code is evolved from.

Glad to see you are using Spock!


On Tue, Apr 16, 2013 at 5:37 PM, Tony Nelson tnel...@starpoint.com wrote:

 I ran into a problem with JSONArray today that I think deserves a bug
 report, but I'm not exactly sure what the correct/expected behavior should
 be, so I'm not sure how to file the bug.

 This test case demonstrates the issue:

 def test add null to array() {
 setup:
 String n = null
 JSONArray obj = new JSONArray()
 obj.put(n)

 when:
 String result = obj.toString()

 then:
 [] == result
 }


 I think I might expect the actual result to be [ null ], but you don't get
 that either, what you do get is a NULL pointer exception.

 java.lang.NullPointerException
 at
 org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:887)
 at org.apache.tapestry5.json.JSONArray.print(JSONArray.java:436)
 at
 org.apache.tapestry5.json.JSONCollection.toString(JSONCollection.java:47)
 at com.starpoint.business.BusLogic1Test.test print empty
 array(BusLogic1Test.groovy:35)

 Looking at the code, it would appear that you don't want null to be a
 valid value (though I would argue it's perfectly fine),

 public JSONArray put(Object value)
 {
 assert value != null;

 JSONObject.testValidity(value);

 list.add(value);

 return this;
 }


 I don't run with assertions enabled (who does??), but apparently
 JSONObject.testValidity passes just fine. You don't run into a problem
 until you actually try to print the array (or return it as an ajax
 response).

 What is the correct behavior?
 Tony

 Since 1982, Starpoint Solutions has been a trusted source of human capital
 and solutions. We are committed to our clients, employees, environment,
 community and social concerns.  We foster an inclusive culture based on
 trust, respect, honesty and solid performance. Learn more about Starpoint
 and our social responsibility at
 http://www.starpoint.com/social_responsibility

 This email message from Starpoint Solutions LLC is for the sole use of
  the intended recipient(s) and may contain confidential and privileged
  information.  Any unauthorized review, use, disclosure or distribution is
 prohibited.  If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.
  Opinions, conclusions and other information in this message that do not
 relate to the official business of Starpoint Solutions shall be understood
 as neither given nor endorsed by it.

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: Help with bug report

2013-04-16 Thread Howard Lewis Ship
I'd need to review the code to determine the why of JSONObject.NULL.  I'm
at a client today (doing Clojure and AngularJS!) so I can't really divert.


On Tue, Apr 16, 2013 at 6:36 PM, Tony Nelson tnel...@starpoint.com wrote:

 So wouldn't it be DRY to convert null to JSONObject.NULL in put()?

 Sorry so terse on iPhone @lunch.

 On Apr 16, 2013, at 1:28 PM, Howard Lewis Ship hls...@gmail.com wrote:

  Obviously it would blow up if you ran with -ea
 
  The docs specify the acceptable values for put().
 
  You don't use a null, you use JSONObject.NULL.
 
  I can't remember why it is done this way; it may have simply been done
 that
  way in the original JSON.org source that the Tapestry code is evolved
 from.
 
  Glad to see you are using Spock!
 
 
  On Tue, Apr 16, 2013 at 5:37 PM, Tony Nelson tnel...@starpoint.com
 wrote:
 
  I ran into a problem with JSONArray today that I think deserves a bug
  report, but I'm not exactly sure what the correct/expected behavior
 should
  be, so I'm not sure how to file the bug.
 
  This test case demonstrates the issue:
 
 def test add null to array() {
 setup:
 String n = null
 JSONArray obj = new JSONArray()
 obj.put(n)
 
 when:
 String result = obj.toString()
 
 then:
 [] == result
 }
 
 
  I think I might expect the actual result to be [ null ], but you don't
 get
  that either, what you do get is a NULL pointer exception.
 
  java.lang.NullPointerException
 at
  org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:887)
 at org.apache.tapestry5.json.JSONArray.print(JSONArray.java:436)
 at
 
 org.apache.tapestry5.json.JSONCollection.toString(JSONCollection.java:47)
 at com.starpoint.business.BusLogic1Test.test print empty
  array(BusLogic1Test.groovy:35)
 
  Looking at the code, it would appear that you don't want null to be a
  valid value (though I would argue it's perfectly fine),
 
 public JSONArray put(Object value)
 {
 assert value != null;
 
 JSONObject.testValidity(value);
 
 list.add(value);
 
 return this;
 }
 
 
  I don't run with assertions enabled (who does??), but apparently
  JSONObject.testValidity passes just fine. You don't run into a problem
  until you actually try to print the array (or return it as an ajax
  response).
 
  What is the correct behavior?
  Tony
 
  Since 1982, Starpoint Solutions has been a trusted source of human
 capital
  and solutions. We are committed to our clients, employees, environment,
  community and social concerns.  We foster an inclusive culture based on
  trust, respect, honesty and solid performance. Learn more about
 Starpoint
  and our social responsibility at
  http://www.starpoint.com/social_responsibility
 
  This email message from Starpoint Solutions LLC is for the sole use of
  the intended recipient(s) and may contain confidential and privileged
  information.  Any unauthorized review, use, disclosure or distribution
 is
  prohibited.  If you are not the intended recipient, please contact the
  sender by reply email and destroy all copies of the original message.
  Opinions, conclusions and other information in this message that do not
  relate to the official business of Starpoint Solutions shall be
 understood
  as neither given nor endorsed by it.
 
  -
  To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
  For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
  --
  Howard M. Lewis Ship
 
  Creator of Apache Tapestry
 
  The source for Tapestry training, mentoring and support. Contact me to
  learn how I can get you up and productive in Tapestry fast!
 
  (971) 678-5210
  http://howardlewisship.com

 Since 1982, Starpoint Solutions has been a trusted source of human capital
 and solutions. We are committed to our clients, employees, environment,
 community and social concerns.  We foster an inclusive culture based on
 trust, respect, honesty and solid performance. Learn more about Starpoint
 and our social responsibility at
 http://www.starpoint.com/social_responsibility

 This email message from Starpoint Solutions LLC is for the sole use of
  the intended recipient(s) and may contain confidential and privileged
  information.  Any unauthorized review, use, disclosure or distribution is
 prohibited.  If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.
  Opinions, conclusions and other information in this message that do not
 relate to the official business of Starpoint Solutions shall be understood
 as neither given nor endorsed by it.

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of 

Re: Help with bug report

2013-04-16 Thread Tony Nelson
I guess the question still remains.  Should I file a bug report?  For what?

I guess I'm leaning towards JSONArray.put(null) should throw an exception, that 
way you know exactly when you're screwing up.

Thoughts?

On Apr 16, 2013, at 1:49 PM, Howard Lewis Ship hls...@gmail.com wrote:

 I'd need to review the code to determine the why of JSONObject.NULL.  I'm
 at a client today (doing Clojure and AngularJS!) so I can't really divert.


 On Tue, Apr 16, 2013 at 6:36 PM, Tony Nelson tnel...@starpoint.com wrote:

 So wouldn't it be DRY to convert null to JSONObject.NULL in put()?

 Sorry so terse on iPhone @lunch.

 On Apr 16, 2013, at 1:28 PM, Howard Lewis Ship hls...@gmail.com wrote:

 Obviously it would blow up if you ran with -ea

 The docs specify the acceptable values for put().

 You don't use a null, you use JSONObject.NULL.

 I can't remember why it is done this way; it may have simply been done
 that
 way in the original JSON.org source that the Tapestry code is evolved
 from.

 Glad to see you are using Spock!


 On Tue, Apr 16, 2013 at 5:37 PM, Tony Nelson tnel...@starpoint.com
 wrote:

 I ran into a problem with JSONArray today that I think deserves a bug
 report, but I'm not exactly sure what the correct/expected behavior
 should
 be, so I'm not sure how to file the bug.

 This test case demonstrates the issue:

   def test add null to array() {
   setup:
   String n = null
   JSONArray obj = new JSONArray()
   obj.put(n)

   when:
   String result = obj.toString()

   then:
   [] == result
   }


 I think I might expect the actual result to be [ null ], but you don't
 get
 that either, what you do get is a NULL pointer exception.

 java.lang.NullPointerException
   at
 org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:887)
   at org.apache.tapestry5.json.JSONArray.print(JSONArray.java:436)
   at

 org.apache.tapestry5.json.JSONCollection.toString(JSONCollection.java:47)
   at com.starpoint.business.BusLogic1Test.test print empty
 array(BusLogic1Test.groovy:35)

 Looking at the code, it would appear that you don't want null to be a
 valid value (though I would argue it's perfectly fine),

   public JSONArray put(Object value)
   {
   assert value != null;

   JSONObject.testValidity(value);

   list.add(value);

   return this;
   }


 I don't run with assertions enabled (who does??), but apparently
 JSONObject.testValidity passes just fine. You don't run into a problem
 until you actually try to print the array (or return it as an ajax
 response).

 What is the correct behavior?
 Tony

 Since 1982, Starpoint Solutions has been a trusted source of human
 capital
 and solutions. We are committed to our clients, employees, environment,
 community and social concerns.  We foster an inclusive culture based on
 trust, respect, honesty and solid performance. Learn more about
 Starpoint
 and our social responsibility at
 http://www.starpoint.com/social_responsibility

 This email message from Starpoint Solutions LLC is for the sole use of
 the intended recipient(s) and may contain confidential and privileged
 information.  Any unauthorized review, use, disclosure or distribution
 is
 prohibited.  If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.
 Opinions, conclusions and other information in this message that do not
 relate to the official business of Starpoint Solutions shall be
 understood
 as neither given nor endorsed by it.

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org


 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.com

 Since 1982, Starpoint Solutions has been a trusted source of human capital
 and solutions. We are committed to our clients, employees, environment,
 community and social concerns.  We foster an inclusive culture based on
 trust, respect, honesty and solid performance. Learn more about Starpoint
 and our social responsibility at
 http://www.starpoint.com/social_responsibility

 This email message from Starpoint Solutions LLC is for the sole use of
 the intended recipient(s) and may contain confidential and privileged
 information.  Any unauthorized review, use, disclosure or distribution is
 prohibited.  If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.
 Opinions, conclusions and other information in this message that do not
 relate to the official business of Starpoint Solutions shall be understood
 as neither given nor endorsed by it.

 -
 To 

Re: Help with bug report

2013-04-16 Thread Josh Canfield
I haven't had a chance to look at the code, but:

 I guess I'm leaning towards JSONArray.put(null) should throw an
exception, that way you know exactly when you're screwing up.

Since null is a valid value in the JSON array, it seems like the null
pointer exception should get fixed. Perhaps put needs to convert null into
JSONObject.NULL?


On Tue, Apr 16, 2013 at 11:12 AM, Tony Nelson tnel...@starpoint.com wrote:

 I guess the question still remains.  Should I file a bug report?  For what?

 I guess I'm leaning towards JSONArray.put(null) should throw an exception,
 that way you know exactly when you're screwing up.

 Thoughts?

 On Apr 16, 2013, at 1:49 PM, Howard Lewis Ship hls...@gmail.com wrote:

  I'd need to review the code to determine the why of JSONObject.NULL.  I'm
  at a client today (doing Clojure and AngularJS!) so I can't really
 divert.
 
 
  On Tue, Apr 16, 2013 at 6:36 PM, Tony Nelson tnel...@starpoint.com
 wrote:
 
  So wouldn't it be DRY to convert null to JSONObject.NULL in put()?
 
  Sorry so terse on iPhone @lunch.
 
  On Apr 16, 2013, at 1:28 PM, Howard Lewis Ship hls...@gmail.com
 wrote:
 
  Obviously it would blow up if you ran with -ea
 
  The docs specify the acceptable values for put().
 
  You don't use a null, you use JSONObject.NULL.
 
  I can't remember why it is done this way; it may have simply been done
  that
  way in the original JSON.org source that the Tapestry code is evolved
  from.
 
  Glad to see you are using Spock!
 
 
  On Tue, Apr 16, 2013 at 5:37 PM, Tony Nelson tnel...@starpoint.com
  wrote:
 
  I ran into a problem with JSONArray today that I think deserves a bug
  report, but I'm not exactly sure what the correct/expected behavior
  should
  be, so I'm not sure how to file the bug.
 
  This test case demonstrates the issue:
 
def test add null to array() {
setup:
String n = null
JSONArray obj = new JSONArray()
obj.put(n)
 
when:
String result = obj.toString()
 
then:
[] == result
}
 
 
  I think I might expect the actual result to be [ null ], but you don't
  get
  that either, what you do get is a NULL pointer exception.
 
  java.lang.NullPointerException
at
  org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:887)
at org.apache.tapestry5.json.JSONArray.print(JSONArray.java:436)
at
 
 
 org.apache.tapestry5.json.JSONCollection.toString(JSONCollection.java:47)
at com.starpoint.business.BusLogic1Test.test print empty
  array(BusLogic1Test.groovy:35)
 
  Looking at the code, it would appear that you don't want null to be a
  valid value (though I would argue it's perfectly fine),
 
public JSONArray put(Object value)
{
assert value != null;
 
JSONObject.testValidity(value);
 
list.add(value);
 
return this;
}
 
 
  I don't run with assertions enabled (who does??), but apparently
  JSONObject.testValidity passes just fine. You don't run into a problem
  until you actually try to print the array (or return it as an ajax
  response).
 
  What is the correct behavior?
  Tony
 
  Since 1982, Starpoint Solutions has been a trusted source of human
  capital
  and solutions. We are committed to our clients, employees,
 environment,
  community and social concerns.  We foster an inclusive culture based
 on
  trust, respect, honesty and solid performance. Learn more about
  Starpoint
  and our social responsibility at
  http://www.starpoint.com/social_responsibility
 
  This email message from Starpoint Solutions LLC is for the sole use of
  the intended recipient(s) and may contain confidential and privileged
  information.  Any unauthorized review, use, disclosure or distribution
  is
  prohibited.  If you are not the intended recipient, please contact the
  sender by reply email and destroy all copies of the original message.
  Opinions, conclusions and other information in this message that do
 not
  relate to the official business of Starpoint Solutions shall be
  understood
  as neither given nor endorsed by it.
 
  -
  To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
  For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
  --
  Howard M. Lewis Ship
 
  Creator of Apache Tapestry
 
  The source for Tapestry training, mentoring and support. Contact me to
  learn how I can get you up and productive in Tapestry fast!
 
  (971) 678-5210
  http://howardlewisship.com
 
  Since 1982, Starpoint Solutions has been a trusted source of human
 capital
  and solutions. We are committed to our clients, employees, environment,
  community and social concerns.  We foster an inclusive culture based on
  trust, respect, honesty and solid performance. Learn more about
 Starpoint
  and our social responsibility at
  http://www.starpoint.com/social_responsibility
 
  This email message from Starpoint Solutions LLC is for the sole