flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject [2/2] git commit: FLUME-1652. Logutils.getLogs could throw NPE.
Date Fri, 26 Oct 2012 03:33:28 GMT
FLUME-1652. Logutils.getLogs could throw NPE.

(Brock Noland via Hari Shreedharan)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/1ee1ce49
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/1ee1ce49
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/1ee1ce49

Branch: refs/heads/flume-1.3.0
Commit: 1ee1ce49e6b609649ef4790e7708ed8663baac76
Parents: af711b3
Author: Hari Shreedharan <hshreedharan@apache.org>
Authored: Sun Oct 21 12:20:15 2012 -0700
Committer: Hari Shreedharan <hshreedharan@apache.org>
Committed: Thu Oct 25 23:29:39 2012 -0400

----------------------------------------------------------------------
 .../org/apache/flume/channel/file/LogUtils.java    |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/1ee1ce49/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogUtils.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogUtils.java
b/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogUtils.java
index 13f7298..4f5d3cc 100644
--- a/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogUtils.java
+++ b/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogUtils.java
@@ -63,7 +63,18 @@ public class LogUtils {
    */
   static List<File> getLogs(File logDir) {
     List<File> result = Lists.newArrayList();
-    for (File file : logDir.listFiles()) {
+    File[] files = logDir.listFiles();
+    if(files == null) {
+      if(!logDir.isDirectory()) {
+        String msg = "Path " + logDir + " is not a directory: ";
+        msg += "File = " + logDir.isFile() + ", ";
+        msg += "Exists = " + logDir.exists() + ", ";
+        msg += "Writable = " + logDir.canWrite();
+        throw new IllegalStateException(msg);
+      }
+      return result;
+    }
+    for (File file : files) {
       String name = file.getName();
       if (pattern.matcher(name).matches()) {
         result.add(file);


Mime
View raw message