Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B333C18227 for ; Tue, 29 Sep 2015 23:12:37 +0000 (UTC) Received: (qmail 6796 invoked by uid 500); 29 Sep 2015 23:12:37 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 6742 invoked by uid 500); 29 Sep 2015 23:12:37 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 6728 invoked by uid 99); 29 Sep 2015 23:12:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Sep 2015 23:12:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5A659E0418; Tue, 29 Sep 2015 23:12:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ctubbsii@apache.org To: commits@accumulo.apache.org Date: Tue, 29 Sep 2015 23:12:40 -0000 Message-Id: <5fe271dd94524dbfaefd4bdf1a443b81@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/12] accumulo git commit: ACCUMULO-4013 Clean up exception handling ACCUMULO-4013 Clean up exception handling Prevent Eclipse (and possibly other IDEs) from getting confused about unclosed resources in SendLogToChainsaw utility with a slight refactoring. This change ensures the FileNotFoundException wraps the constructor where it occurs, and the rest of the InputStream construction occurs outside of that try/catch block. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/9c206aa8 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/9c206aa8 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/9c206aa8 Branch: refs/heads/master Commit: 9c206aa8f195e0557864289de7d63096915a7cd4 Parents: c05ab0a Author: Christopher Tubbs Authored: Tue Sep 29 18:35:34 2015 -0400 Committer: Christopher Tubbs Committed: Tue Sep 29 18:35:34 2015 -0400 ---------------------------------------------------------------------- .../apache/accumulo/server/util/SendLogToChainsaw.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/9c206aa8/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java index cbf7e2d..f38eb24 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java @@ -56,8 +56,8 @@ import com.beust.jcommander.Parameter; public class SendLogToChainsaw extends XMLLayout { - private static Pattern logPattern = Pattern.compile( - "^(\\d\\d)\\s(\\d\\d):(\\d\\d):(\\d\\d),(\\d\\d\\d)\\s\\[(.*)\\]\\s(TRACE|DEBUG|INFO|WARN|FATAL|ERROR)\\s*?:(.*)$", Pattern.UNIX_LINES); + private static Pattern logPattern = Pattern + .compile("^(\\d\\d)\\s(\\d\\d):(\\d\\d):(\\d\\d),(\\d\\d\\d)\\s\\[(.*)\\]\\s(TRACE|DEBUG|INFO|WARN|FATAL|ERROR)\\s*?:(.*)$", Pattern.UNIX_LINES); private File[] logFiles = null; @@ -117,19 +117,19 @@ public class SendLogToChainsaw extends XMLLayout { public void processLogFiles() throws IOException { String line = null; String out = null; - InputStreamReader isReader = null; BufferedReader reader = null; try { for (File log : logFiles) { // Parse the server type and name from the log file name String threadName = log.getName().substring(0, log.getName().indexOf(".")); + FileInputStream fis; try { - isReader = new InputStreamReader(new FileInputStream(log), UTF_8); + fis = new FileInputStream(log); } catch (FileNotFoundException e) { System.out.println("Unable to find file: " + log.getAbsolutePath()); throw e; } - reader = new BufferedReader(isReader); + reader = new BufferedReader(new InputStreamReader(fis, UTF_8)); try { line = reader.readLine(); @@ -150,9 +150,6 @@ public class SendLogToChainsaw extends XMLLayout { if (reader != null) { reader.close(); } - if (isReader != null) { - isReader.close(); - } } } } finally {