flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject [11/24] git commit: FLUME-1652. Logutils.getLogs could throw NPE.
Date Tue, 30 Oct 2012 22:59:40 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/5416e77e
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/5416e77e
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/5416e77e

Branch: refs/heads/FLUME-1502
Commit: 5416e77e16bb1906ed3b64754301825c5aeea6b3
Parents: bc1928b
Author: Hari Shreedharan <hshreedharan@apache.org>
Authored: Sun Oct 21 12:20:15 2012 -0700
Committer: Hari Shreedharan <hshreedharan@apache.org>
Committed: Sun Oct 21 12:20:15 2012 -0700

----------------------------------------------------------------------
 .../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/5416e77e/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