GEODE-2649: Export logs does not use file creation time
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9ade1d32 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9ade1d32 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9ade1d32 Branch: refs/heads/feature/GEODE-2420 Commit: 9ade1d322d1850c099eb9375441ffa65315283d2 Parents: 41e669d Author: Jared Stewart <[email protected]> Authored: Thu Mar 16 11:12:50 2017 -0700 Committer: Ken Howe <[email protected]> Committed: Mon Mar 27 14:00:41 2017 -0700 ---------------------------------------------------------------------- .../management/internal/cli/util/LogFilter.java | 23 ++------------------ .../internal/cli/util/LogFilterTest.java | 5 ++--- 2 files changed, 4 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/9ade1d32/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java index 0da6ddf..d896243 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java @@ -99,19 +99,11 @@ public class LogFilter { } public boolean acceptsFile(Path file) { - if (startDate == null && endDate == null) { - return true; - } - - if (endDate == null) { - return getEndTimeOf(file).isAfter(startDate); - } - if (startDate == null) { - return getStartTimeOf(file).isBefore(endDate); + return true; } - return (getEndTimeOf(file).isAfter(startDate) && getStartTimeOf(file).isBefore(endDate)); + return getEndTimeOf(file).isAfter(startDate); } @@ -126,15 +118,4 @@ public class LogFilter { } } - private static LocalDateTime getStartTimeOf(Path file) { - try { - BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class); - long lastModifiedMillis = attributes.creationTime().toMillis(); - return Instant.ofEpochMilli(lastModifiedMillis).atZone(ZoneId.systemDefault()) - .toLocalDateTime(); - } catch (Exception e) { - LOGGER.error("Unable to determine creation time", e); - return LocalDateTime.MIN; - } - } } http://git-wip-us.apache.org/repos/asf/geode/blob/9ade1d32/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java index d29e4de..becc26d 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java @@ -188,7 +188,6 @@ public class LogFilterTest { when(path.getFileSystem().provider()).thenReturn(mock(FileSystemProvider.class)); when(path.getFileSystem().provider().readAttributes(path, BasicFileAttributes.class)) .thenReturn(attributes); - when(attributes.creationTime()).thenReturn(FileTime.fromMillis(now - 10000)); // a filter with no start/end date should accept this file LogFilter filter = new LogFilter(Level.INFO, null, null); @@ -206,8 +205,8 @@ public class LogFilterTest { filter = new LogFilter(Level.INFO, null, LocalDateTime.now()); assertThat(filter.acceptsFile(path)).isTrue(); - // a filter with an end date of an hour ago should not accept the file + // a filter with an end date of an hour ago should accept the file filter = new LogFilter(Level.INFO, null, LocalDateTime.now().minusHours(1)); - assertThat(filter.acceptsFile(path)).isFalse(); + assertThat(filter.acceptsFile(path)).isTrue(); } }
