Updated Branches: refs/heads/flume-1.4 80fe9324f -> f3b64e797
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/f3b64e79 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/f3b64e79 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/f3b64e79 Branch: refs/heads/flume-1.4 Commit: f3b64e79796d63b15be980d83840c0c68ff3dc87 Parents: 80fe932 Author: Hari Shreedharan <[email protected]> Authored: Sun Oct 21 12:20:15 2012 -0700 Committer: Hari Shreedharan <[email protected]> Committed: Sun Oct 21 12:21:41 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/f3b64e79/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);
