tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <>
Subject Re: How do I ........?
Date Wed, 15 Nov 2006 23:47:08 GMT
This is one of those SS!=DS discussions which means that variables placed/alloc'ed on the stack
are NOT the same as variables alloc'ed from heap
when using a variable which is  alloced  on the stack AND initialised to some known value
feel free to test that pre-allocated stack variable as with if(stack_variable == null)

If you dont know how this variable is alloc'ed or you know that the variable is alloc'ed from
heap use try / catch(NullPointerException npe)

to do otherwise you're risking your webapp causing 'an unhandled exception' when referencing
a unalloc'ed variable..

This e-mail communication and any attachments may contain confidential and privileged information
for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified
that you have received
this communication in error and that any review, disclosure, dissemination, distribution or
copying of it or its 
----- Original Message ----- 
From: "Steve R Burrus" <>
To: "Tomcat Users List" <>
Sent: Wednesday, November 15, 2006 2:35 PM
Subject: Re: How do I ........?

> just a tiny correction for you Chris, and that is that the code ought to 
> be "if(in = = null)" not as u had it "if(null = = in)". Am I right or not?
> Christopher Schultz wrote:
>>Hash: SHA1
>>Steve R Burrus wrote:
>>>hi chris this is steve Burrus and the line of code in question is the
>>>while loop : "while( ( r = != -1) {" the server error for a
>>>long time has always pointed to that line of code creating the NPE.
>>Yup, that's the first time you use the InputStream after attempting to
>>load your file. It's pretty simple to check for null: just use the code
>>I suggested in my last message:
>>>>Correct me if I'm wrong, but this generally checks for null:
>>>>if(null == in)
>>>>  // handle the null condition
>>Now, it's up to you what you want to do in the event of a NULL image.
>>You could either return a "404 Not Found" error status, or return a
>>known good image that actually says "ERROR" on it.
>>- -chris
>>Version: GnuPG v1.4.5 (MingW32)
>>Comment: Using GnuPG with Mozilla -
>>To start a new topic, e-mail:
>>To unsubscribe, e-mail:
>>For additional commands, e-mail:
View raw message