Alexey, Yes, I agree this is the better way.
But.. I have to catch a potential IOException (which can also occur) anyway so I personally thought it would be better use Exception to catch both exceptions at once (in the unlikely event they occur). I have already changed the code to check for null; Regards, Patrick M. Ansari [EMAIL PROTECTED] ------------------------------------ 186 East Road, R5.1 CB1 1BG Cambridge, Cambridgeshire United Kingdom Phone: +44 (0) 1223 475578 ------------------------------------ -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Alexey A. Efimov Sent: 08 April 2002 16:28 To: [EMAIL PROTECTED] Subject: RE: [Eap-list] [615] Code Inspection: Exception suggested Patric, NPE checker work correct. Exactly - this place may throw NPE, isn't it? So you can ignore it or make a fix: if (connection != null) { connection.close(); } Why don't catch NPE? Becose, first, imagene that you have a pool. So you make free connection in finalise block: } finally { pool.freeConnection(connection); } So that do pool if connection parameter is null? Throw NPE? I think it just must ignore it. It easily that throw and catch exception. Just check it on null. and, second, why catch non-informatical and non-usability in this context exceptions? It's hard work in code. I must make code easy. -----Original Message----- From: Maxim Shafirov [mailto:[EMAIL PROTECTED]] Sent: Monday, April 08, 2002 7:04 PM To: Patrick M. Ansari Subject: Re: [Eap-list] [615] Code Inspection: Exception suggested Hello Patrick, Isn't it quite correct? close call could actually throw NPE. Inspector just does not bother if certain exception get's the chance to be catched. IMHO it would be much more clear to check if (outBuff != null) outBuff.close(); instead of catching an exception here. -- Best regards, Maxim Shafirov JetBrains, Inc / IntelliJ Software http://www.intellij.com "Develop with pleasure!" PMA> finally PMA> { PMA> try PMA> { PMA> outBuff.close(); PMA> } PMA> catch (Exception e) PMA> { PMA> e.printStackTrace(); PMA> } PMA> } PMA> Keeps telling me that .close() could throw a NullPointerException PMA> even though all exceptions should be covered by Exception e.. PMA> . PMA> Regards, PMA> Patrick M. Ansari PMA> [EMAIL PROTECTED] PMA> ------------------------------------ PMA> 186 East Road, R5.1 PMA> CB1 1BG Cambridge, Cambridgeshire PMA> United Kingdom PMA> Phone: +44 (0) 1223 475578 PMA> ------------------------------------ _______________________________________________ Eap-list mailing list [EMAIL PROTECTED] http://www.intellij.com/mailman/listinfo/eap-list _______________________________________________ Eap-list mailing list [EMAIL PROTECTED] http://www.intellij.com/mailman/listinfo/eap-list _______________________________________________ Eap-list mailing list [EMAIL PROTECTED] http://www.intellij.com/mailman/listinfo/eap-list
