You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by sa...@apache.org on 2013/07/31 23:23:52 UTC

svn commit: r1509038 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java

Author: sallen
Date: Wed Jul 31 21:23:52 2013
New Revision: 1509038

URL: http://svn.apache.org/r1509038
Log:
Replace incorrect IllegalArgumentException with a NullPointerException

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java?rev=1509038&r1=1509037&r2=1509038&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java Wed Jul 31 21:23:52 2013
@@ -58,7 +58,7 @@ public class UpdateWriter implements Clo
     public UpdateWriter(IndentedWriter out, SerializationContext sCxt)
     {
         if (out == null)
-            throw new IllegalArgumentException("out may not be null") ;
+            throw new NullPointerException("out") ;
         
         // To get legal syntax out, the serialization context 
         // has to be a bNode mapping that does ??N vars to bNodes



Re: svn commit: r1509038 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java

Posted by Stephen Allen <sa...@apache.org>.
Yep, one of the numerous ways in which C# is a much better language :)


On Wed, Jul 31, 2013 at 5:55 PM, Rob Vesse <rv...@yarcdata.com> wrote:

> Fair enough
>
> C# is nicer in that it has a NullReferenceException, ArgumentNullException
> and ArgumentException
>
> Rob
>
>
> On 7/31/13 2:48 PM, "Stephen Allen" <sa...@apache.org> wrote:
>
> >The Java documentation is rather lacking in this area.  But I *think* the
> >standard in Java is to throw NPE, even though it seems a little
> >counter-intuitive.  I base this off of recent experience using Guava a lot
> >for precondition checking, and it favors NPE [1], and also Effective Java
> >[2] which also says to use NPE.
> >
> >-Stephen
> >
> >[1] https://code.google.com/p/guava-libraries/wiki/PreconditionsExplained
> >[2] Effective Java 2nd Edition, Item 60: "Arguably, all erroneous method
> >invocations boil down to an illegal argument or illegal state, but other
> >exceptions are standardly used for certain kinds of illegal arguments and
> >states. If a caller passes null in some parameter for which null values
> >are
> >prohibited, convention dictates that NullPointerException be thrown rather
> >than IllegalArgumentException. Similarly, if a caller passes an
> >out-of-range value in a parameter representing an index into a sequence,
> >IndexOutOfBoundsException should be thrown rather than
> >IllegalArgumentException."
> >
> >
> >On Wed, Jul 31, 2013 at 5:27 PM, Rob Vesse <rv...@yarcdata.com> wrote:
> >
> >> Isn't IllegalArgumentException actually more appropriate here?
> >>
> >> There's a difference between a NPE which is typically something that
> >> shouldn't have been null being null and an IAE which is used for when
> >> arguments don't meet the contract of the API which was the case here.
> >>
> >> Rob
> >>
> >>
> >> On 7/31/13 2:23 PM, "sallen@apache.org" <sa...@apache.org> wrote:
> >>
> >> >Author: sallen
> >> >Date: Wed Jul 31 21:23:52 2013
> >> >New Revision: 1509038
> >> >
> >> >URL: http://svn.apache.org/r1509038
> >> >Log:
> >> >Replace incorrect IllegalArgumentException with a NullPointerException
> >> >
> >> >Modified:
> >> >
> >>
> >>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
> >>>Up
> >> >dateWriter.java
> >> >
> >> >Modified:
> >>
> >>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
> >>>Up
> >> >dateWriter.java
> >> >URL:
> >> >
> >>
> >>
> http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl
> >>/
> >>
> >>>jena/sparql/modify/request/UpdateWriter.java?rev=1509038&r1=1509037&r2=1
> >>>50
> >> >9038&view=diff
> >>
> >>>========================================================================
> >>>==
> >> >====
> >> >---
> >>
> >>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
> >>>Up
> >> >dateWriter.java (original)
> >> >+++
> >>
> >>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
> >>>Up
> >> >dateWriter.java Wed Jul 31 21:23:52 2013
> >> >@@ -58,7 +58,7 @@ public class UpdateWriter implements Clo
> >> >     public UpdateWriter(IndentedWriter out, SerializationContext sCxt)
> >> >     {
> >> >         if (out == null)
> >> >-            throw new IllegalArgumentException("out may not be null")
> >>;
> >> >+            throw new NullPointerException("out") ;
> >> >
> >> >         // To get legal syntax out, the serialization context
> >> >         // has to be a bNode mapping that does ??N vars to bNodes
> >> >
> >> >
> >>
> >>
>
>

Re: svn commit: r1509038 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java

Posted by Rob Vesse <rv...@yarcdata.com>.
Fair enough

C# is nicer in that it has a NullReferenceException, ArgumentNullException
and ArgumentException

Rob


On 7/31/13 2:48 PM, "Stephen Allen" <sa...@apache.org> wrote:

>The Java documentation is rather lacking in this area.  But I *think* the
>standard in Java is to throw NPE, even though it seems a little
>counter-intuitive.  I base this off of recent experience using Guava a lot
>for precondition checking, and it favors NPE [1], and also Effective Java
>[2] which also says to use NPE.
>
>-Stephen
>
>[1] https://code.google.com/p/guava-libraries/wiki/PreconditionsExplained
>[2] Effective Java 2nd Edition, Item 60: "Arguably, all erroneous method
>invocations boil down to an illegal argument or illegal state, but other
>exceptions are standardly used for certain kinds of illegal arguments and
>states. If a caller passes null in some parameter for which null values
>are
>prohibited, convention dictates that NullPointerException be thrown rather
>than IllegalArgumentException. Similarly, if a caller passes an
>out-of-range value in a parameter representing an index into a sequence,
>IndexOutOfBoundsException should be thrown rather than
>IllegalArgumentException."
>
>
>On Wed, Jul 31, 2013 at 5:27 PM, Rob Vesse <rv...@yarcdata.com> wrote:
>
>> Isn't IllegalArgumentException actually more appropriate here?
>>
>> There's a difference between a NPE which is typically something that
>> shouldn't have been null being null and an IAE which is used for when
>> arguments don't meet the contract of the API which was the case here.
>>
>> Rob
>>
>>
>> On 7/31/13 2:23 PM, "sallen@apache.org" <sa...@apache.org> wrote:
>>
>> >Author: sallen
>> >Date: Wed Jul 31 21:23:52 2013
>> >New Revision: 1509038
>> >
>> >URL: http://svn.apache.org/r1509038
>> >Log:
>> >Replace incorrect IllegalArgumentException with a NullPointerException
>> >
>> >Modified:
>> >
>> 
>>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
>>>Up
>> >dateWriter.java
>> >
>> >Modified:
>> 
>>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
>>>Up
>> >dateWriter.java
>> >URL:
>> >
>> 
>>http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl
>>/
>> 
>>>jena/sparql/modify/request/UpdateWriter.java?rev=1509038&r1=1509037&r2=1
>>>50
>> >9038&view=diff
>> 
>>>========================================================================
>>>==
>> >====
>> >---
>> 
>>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
>>>Up
>> >dateWriter.java (original)
>> >+++
>> 
>>>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/
>>>Up
>> >dateWriter.java Wed Jul 31 21:23:52 2013
>> >@@ -58,7 +58,7 @@ public class UpdateWriter implements Clo
>> >     public UpdateWriter(IndentedWriter out, SerializationContext sCxt)
>> >     {
>> >         if (out == null)
>> >-            throw new IllegalArgumentException("out may not be null")
>>;
>> >+            throw new NullPointerException("out") ;
>> >
>> >         // To get legal syntax out, the serialization context
>> >         // has to be a bNode mapping that does ??N vars to bNodes
>> >
>> >
>>
>>


Re: svn commit: r1509038 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java

Posted by Stephen Allen <sa...@apache.org>.
The Java documentation is rather lacking in this area.  But I *think* the
standard in Java is to throw NPE, even though it seems a little
counter-intuitive.  I base this off of recent experience using Guava a lot
for precondition checking, and it favors NPE [1], and also Effective Java
[2] which also says to use NPE.

-Stephen

[1] https://code.google.com/p/guava-libraries/wiki/PreconditionsExplained
[2] Effective Java 2nd Edition, Item 60: "Arguably, all erroneous method
invocations boil down to an illegal argument or illegal state, but other
exceptions are standardly used for certain kinds of illegal arguments and
states. If a caller passes null in some parameter for which null values are
prohibited, convention dictates that NullPointerException be thrown rather
than IllegalArgumentException. Similarly, if a caller passes an
out-of-range value in a parameter representing an index into a sequence,
IndexOutOfBoundsException should be thrown rather than
IllegalArgumentException."


On Wed, Jul 31, 2013 at 5:27 PM, Rob Vesse <rv...@yarcdata.com> wrote:

> Isn't IllegalArgumentException actually more appropriate here?
>
> There's a difference between a NPE which is typically something that
> shouldn't have been null being null and an IAE which is used for when
> arguments don't meet the contract of the API which was the case here.
>
> Rob
>
>
> On 7/31/13 2:23 PM, "sallen@apache.org" <sa...@apache.org> wrote:
>
> >Author: sallen
> >Date: Wed Jul 31 21:23:52 2013
> >New Revision: 1509038
> >
> >URL: http://svn.apache.org/r1509038
> >Log:
> >Replace incorrect IllegalArgumentException with a NullPointerException
> >
> >Modified:
> >
> >jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
> >dateWriter.java
> >
> >Modified:
> >jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
> >dateWriter.java
> >URL:
> >
> http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/
> >jena/sparql/modify/request/UpdateWriter.java?rev=1509038&r1=1509037&r2=150
> >9038&view=diff
> >==========================================================================
> >====
> >---
> >jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
> >dateWriter.java (original)
> >+++
> >jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
> >dateWriter.java Wed Jul 31 21:23:52 2013
> >@@ -58,7 +58,7 @@ public class UpdateWriter implements Clo
> >     public UpdateWriter(IndentedWriter out, SerializationContext sCxt)
> >     {
> >         if (out == null)
> >-            throw new IllegalArgumentException("out may not be null") ;
> >+            throw new NullPointerException("out") ;
> >
> >         // To get legal syntax out, the serialization context
> >         // has to be a bNode mapping that does ??N vars to bNodes
> >
> >
>
>

Re: svn commit: r1509038 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java

Posted by Rob Vesse <rv...@yarcdata.com>.
Isn't IllegalArgumentException actually more appropriate here?

There's a difference between a NPE which is typically something that
shouldn't have been null being null and an IAE which is used for when
arguments don't meet the contract of the API which was the case here.

Rob


On 7/31/13 2:23 PM, "sallen@apache.org" <sa...@apache.org> wrote:

>Author: sallen
>Date: Wed Jul 31 21:23:52 2013
>New Revision: 1509038
>
>URL: http://svn.apache.org/r1509038
>Log:
>Replace incorrect IllegalArgumentException with a NullPointerException
>
>Modified:
>    
>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
>dateWriter.java
>
>Modified: 
>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
>dateWriter.java
>URL: 
>http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/
>jena/sparql/modify/request/UpdateWriter.java?rev=1509038&r1=1509037&r2=150
>9038&view=diff
>==========================================================================
>====
>--- 
>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
>dateWriter.java (original)
>+++ 
>jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/Up
>dateWriter.java Wed Jul 31 21:23:52 2013
>@@ -58,7 +58,7 @@ public class UpdateWriter implements Clo
>     public UpdateWriter(IndentedWriter out, SerializationContext sCxt)
>     {
>         if (out == null)
>-            throw new IllegalArgumentException("out may not be null") ;
>+            throw new NullPointerException("out") ;
>         
>         // To get legal syntax out, the serialization context
>         // has to be a bNode mapping that does ??N vars to bNodes
>
>