You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2003/07/16 02:30:32 UTC

[lang] NPEs in StringUtils

All this debate has reminded me that we have not sorted the position on null
handling in StringUtils.

Most of [lang] is quiet with respect to nulls wherever possible. I would
like to extend that to StringUtils. Are there any objections to making this
change? I feel a consistent position would be good.

Now is the time to do this of course (pre 2.0). (Its amazing what you find
when you want to do a release...)

Stephen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] NPEs in StringUtils

Posted by Jerry Cattell <je...@yahoo.com>.
Quiet null handling can cause problems if it is not
properly documented.  I believe it is essential for
StringUtils.  In my case, I only started using
StringUtils BECAUSE it handled nulls quietly.  If I
have to check if the string is null before I pass it
in, I might as well use the equals method on the
string.

Jerry

--- __matthewHawthorne <mh...@alumni.pitt.edu>
wrote:
> As I've stated before, I think that quiet null
> handling leads to errors
> and confusion.  However, it probably makes more
> sense to adapt
> StringUtils the rest of [lang], instead of the
> opposite.
> 
> An insight into my thinking can be presented in
> these two examples,
> which are titled:
> 
> "Exceptions are for exceptional situations"
> 
> - isEmpty(null)
> 
> null isn't empty, but null isn't _not_ empty either.
>  So neither true or
> false is correct.  This is an exceptional situation.
> 
> - chomp(null)
> 
> You can't chomp null.  You can refuse to chomp null
> and return null...
> but in this case, the method isn't doing what it
> claims to do.  It's
> _refusing_ to chomp instead of chomping.   This is
> an exceptional
> situation.
> 
> I understand that this philosophy is more idealistic
> than practical. 
> 
> 
> 
> 
> On Tue, 2003-07-15 at 17:30, Stephen Colebourne
> wrote:
> > All this debate has reminded me that we have not
> sorted the position on null
> > handling in StringUtils.
> > 
> > Most of [lang] is quiet with respect to nulls
> wherever possible. I would
> > like to extend that to StringUtils. Are there any
> objections to making this
> > change? I feel a consistent position would be
> good.
> > 
> > Now is the time to do this of course (pre 2.0).
> (Its amazing what you find
> > when you want to do a release...)
> > 
> > Stephen
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> > 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] NPEs in StringUtils

Posted by __matthewHawthorne <mh...@alumni.pitt.edu>.
As I've stated before, I think that quiet null handling leads to errors
and confusion.  However, it probably makes more sense to adapt
StringUtils the rest of [lang], instead of the opposite.

An insight into my thinking can be presented in these two examples,
which are titled:

"Exceptions are for exceptional situations"

- isEmpty(null)

null isn't empty, but null isn't _not_ empty either.  So neither true or
false is correct.  This is an exceptional situation.

- chomp(null)

You can't chomp null.  You can refuse to chomp null and return null...
but in this case, the method isn't doing what it claims to do.  It's
_refusing_ to chomp instead of chomping.   This is an exceptional
situation.

I understand that this philosophy is more idealistic than practical. 




On Tue, 2003-07-15 at 17:30, Stephen Colebourne wrote:
> All this debate has reminded me that we have not sorted the position on null
> handling in StringUtils.
> 
> Most of [lang] is quiet with respect to nulls wherever possible. I would
> like to extend that to StringUtils. Are there any objections to making this
> change? I feel a consistent position would be good.
> 
> Now is the time to do this of course (pre 2.0). (Its amazing what you find
> when you want to do a release...)
> 
> Stephen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] NPEs in StringUtils

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Yes, I mean adding

if (str == null) {
  return null;  // or whatevers appropriate...
}

to a number of methods in StringUtils.

Currently this is +1, if still so tonight, I will make the changes.

Stephen

----- Original Message -----
From: "Steven Caswell" <st...@mungoknotwise.com>
To: "'Jakarta Commons Developers List'" <co...@jakarta.apache.org>
Sent: Wednesday, July 16, 2003 1:56 AM
Subject: RE: [lang] NPEs in StringUtils


Just want to be sure I understand. By "quiet", I understand you to mean
nulls are handled in some well-defined way other than throwing an exception.
If that is what you meant, then I am +1. Otherwise I'll wait to hear a
clarification :)


Steven Caswell
steve@mungoknotwise.com
a.k.a Mungo Knotwise of Michel Delving
"One ring to rule them all, one ring to find them..."


> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> Sent: Tuesday, July 15, 2003 7:31 PM
> To: Jakarta Commons Developers List
> Subject: [lang] NPEs in StringUtils
>
>
> All this debate has reminded me that we have not sorted the
> position on null handling in StringUtils.
>
> Most of [lang] is quiet with respect to nulls wherever
> possible. I would like to extend that to StringUtils. Are
> there any objections to making this change? I feel a
> consistent position would be good.
>
> Now is the time to do this of course (pre 2.0). (Its amazing
> what you find when you want to do a release...)
>
> Stephen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


RE: [lang] NPEs in StringUtils

Posted by Steven Caswell <st...@mungoknotwise.com>.
Just want to be sure I understand. By "quiet", I understand you to mean
nulls are handled in some well-defined way other than throwing an exception.
If that is what you meant, then I am +1. Otherwise I'll wait to hear a
clarification :)


Steven Caswell
steve@mungoknotwise.com
a.k.a Mungo Knotwise of Michel Delving
"One ring to rule them all, one ring to find them..."


> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
> Sent: Tuesday, July 15, 2003 7:31 PM
> To: Jakarta Commons Developers List
> Subject: [lang] NPEs in StringUtils
> 
> 
> All this debate has reminded me that we have not sorted the 
> position on null handling in StringUtils.
> 
> Most of [lang] is quiet with respect to nulls wherever 
> possible. I would like to extend that to StringUtils. Are 
> there any objections to making this change? I feel a 
> consistent position would be good.
> 
> Now is the time to do this of course (pre 2.0). (Its amazing 
> what you find when you want to do a release...)
> 
> Stephen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org