Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Eclipse doesn't like else Date: Sat, 13 May 2017 20:39:10 -0400 Organization: Aioe.org NNTP Server Lines: 17 Message-ID: References: <3c792901-a05d-4a02-b058-20b9e0576095@googlegroups.com> <2a413b82-4d1c-467f-bd6b-ad8e6534ba81@googlegroups.com> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:36613 On 5/12/2017 2:53 PM, Eric Douglas wrote: > On Friday, May 12, 2017 at 2:30:37 PM UTC-4, Marcel Mueller wrote: >> Eclispe is right. Your code is not exception safe. If an >> SQLException is thrown close will not be executed. close should >> always be called from a finally block. Marcel > > Which seems odd that it doesn't complain if you take out the 3 lines > above the if, or if you pass the query as a variable so you can > execute those 2 prepareStatement commands as one after the if, either > of which would still produce the resource leak if it hits the catch > clause. I don't think Eclipse detects all cases of resource leak. It is still your responsibility. Arne