You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/09/30 01:12:40 UTC
[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 <ct...@apache.org>
Authored: Tue Sep 29 18:35:34 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
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 {