Return-Path: Delivered-To: apmail-hadoop-mapreduce-issues-archive@minotaur.apache.org Received: (qmail 15948 invoked from network); 17 Jan 2011 03:52:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Jan 2011 03:52:13 -0000 Received: (qmail 53138 invoked by uid 500); 17 Jan 2011 03:52:13 -0000 Delivered-To: apmail-hadoop-mapreduce-issues-archive@hadoop.apache.org Received: (qmail 53006 invoked by uid 500); 17 Jan 2011 03:52:10 -0000 Mailing-List: contact mapreduce-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mapreduce-issues@hadoop.apache.org Delivered-To: mailing list mapreduce-issues@hadoop.apache.org Received: (qmail 52530 invoked by uid 99); 17 Jan 2011 03:52:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jan 2011 03:52:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jan 2011 03:52:06 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id p0H3pjeu005627 for ; Mon, 17 Jan 2011 03:51:45 GMT Message-ID: <18744224.6501295236305282.JavaMail.jira@thor> Date: Sun, 16 Jan 2011 22:51:45 -0500 (EST) From: "Laxman (JIRA)" To: mapreduce-issues@hadoop.apache.org Subject: [jira] Commented: (MAPREDUCE-2243) Close all the file streams propely in a finally block to avoid their leakage. In-Reply-To: <7482545.158651294226986721.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MAPREDUCE-2243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12982466#action_12982466 ] Laxman commented on MAPREDUCE-2243: ----------------------------------- @Owen bq. In most cases, the exceptions outside of IOException don't matter much because they will bring down. bq. this leaves the nominal case simple. Note that this is the worst case, if we get an Error every system in Hadoop should shutdown. bq. There is no point in continuing and worrying about lost file handles at that point is too extreme. Yes, I agree to your point in *Error* scenarios. How about some runtime exception which need not be handled in the positive flow? Handling unexpected generic exceptions and errors will result in catch and rethrow pattern. So, I prefer to handle the stream closure in try block as well as in finally block. As per your initial comments Kamesh has corrected to close the streams in try block as well as in finally block. Do you still see some issue with this approach? How handling stream close in catch block is better than handling in try and finally blocks? My opinion on this issue is "Handling stream closures in try and finally block is fool proof and it will avoid some code duplication." > Close all the file streams propely in a finally block to avoid their leakage. > ----------------------------------------------------------------------------- > > Key: MAPREDUCE-2243 > URL: https://issues.apache.org/jira/browse/MAPREDUCE-2243 > Project: Hadoop Map/Reduce > Issue Type: Improvement > Components: jobtracker, tasktracker > Affects Versions: 0.20.1, 0.22.0 > Environment: NA > Reporter: Bhallamudi Venkata Siva Kamesh > Priority: Minor > Original Estimate: 72h > Remaining Estimate: 72h > > In the following classes streams should be closed in finally block to avoid their leakage in the exceptional cases. > CompletedJobStatusStore.java > ------------------------------------------ > dataOut.writeInt(events.length); > for (TaskCompletionEvent event : events) { > event.write(dataOut); > } > dataOut.close() ; > EventWriter.java > ---------------------- > encoder.flush(); > out.close(); > MapTask.java > ------------------- > splitMetaInfo.write(out); > out.close(); > TaskLog > ------------ > 1) str = fis.readLine(); > fis.close(); > 2) dos.writeBytes(Long.toString(new File(logLocation, LogName.SYSLOG > .toString()).length() - prevLogLength) + "\n"); > dos.close(); > TotalOrderPartitioner.java > ----------------------------------- > while (reader.next(key, value)) { > parts.add(key); > key = ReflectionUtils.newInstance(keyClass, conf); > } > reader.close(); -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.