tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Klaasen" <Tom.Klaa...@the-ecorp.com>
Subject RE: Strange NullPointerException in 3.2b2
Date Wed, 02 Aug 2000 11:55:07 GMT
This seems to be a normal Java error?

Consider this line:
null.toUpperCase();

Wouldn't you expect a NullPointerException here? You can't execute any
method on null.

And null is not the same as "", which would indeed not give any errors.

So you'll have to put it in a construct like this:
String myName = (request.getRemoteUser() == null ? null :
request.getRemoteUser().toUpperCase());

Feel free to optimize ;)

tomK


> -----Original Message-----
> From: John Coonrod [mailto:jc@thp.org]
> Sent: woensdag 2 augustus 2000 13:51
> To: tomcat
> Subject: Strange NullPointerException in 3.2b2
> 
> 
> The line of code
> 
>    String MyName=request.getRemoteUser().toUpperCase();
> 
> Generates a java.lang.NullPointerException when 
> authentication is turned 
> off, and I don't think it should. I guess this is actually a 
> jdk 1.2.2 
> error, because I would think a null string would obey the 
> same methods as 
> any other string.
> 
> (Earlier I had thought my problem was coming from Oracle 
> drivers - I was 
> wrong)
> 
> ----------------
> Dr. John Coonrod, Vice President, jc@thp.org
> The Hunger Project, 15 East 26th Street, NY, NY 10010 www.thp.org
> 
> 

Mime
View raw message