From 8af0d153e07c8694e405c4e82d0f4f7110d857b8 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 24 Apr 2017 18:42:19 +0200 Subject: [PATCH 1/2] Updated version to correct value. --- jetty-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index 26b41b9e927..0fefd5ed3df 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.3.18-SNAPSHOT + 9.3.19-SNAPSHOT 4.0.0 jetty-bom From 118652e985b4486b5427654a02b70dcbea9255bb Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 27 Apr 2017 10:57:37 +0200 Subject: [PATCH 2/2] Issue #1507 --- .../jetty/util/RolloverFileOutputStream.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java b/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java index 401ccd0aff0..f4db2930bed 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java @@ -175,9 +175,12 @@ public class RolloverFileOutputStream extends FilterOutputStream if (__rollover==null) __rollover=new Timer(RolloverFileOutputStream.class.getName(),true); - midnight = toMidnight(ZonedDateTime.now(), zone.toZoneId()); + ZonedDateTime now = ZonedDateTime.now(zone.toZoneId()); + midnight = toMidnight(now, zone.toZoneId()); + while (midnight.isBefore(now)) + midnight = nextMidnight(midnight); - scheduleNextRollover(); + scheduleNextRollover(now); } } @@ -205,11 +208,11 @@ public class RolloverFileOutputStream extends FilterOutputStream return dateTime.toLocalDate().plus(1, ChronoUnit.DAYS).atStartOfDay(dateTime.getZone()); } - private void scheduleNextRollover() + private void scheduleNextRollover(ZonedDateTime now) { _rollTask = new RollTask(); midnight = nextMidnight(midnight); - __rollover.schedule(_rollTask,midnight.toInstant().toEpochMilli() - System.currentTimeMillis()); + __rollover.schedule(_rollTask,midnight.toInstant().toEpochMilli() - now.toInstant().toEpochMilli()); } /* ------------------------------------------------------------ */ @@ -276,11 +279,10 @@ public class RolloverFileOutputStream extends FilterOutputStream } /* ------------------------------------------------------------ */ - private void removeOldFiles() + private void removeOldFiles(ZonedDateTime now) { if (_retainDays>0) { - ZonedDateTime now = ZonedDateTime.now(this.midnight.getZone()); now.minus(_retainDays, ChronoUnit.DAYS); long expired = now.toInstant().toEpochMilli(); @@ -354,9 +356,10 @@ public class RolloverFileOutputStream extends FilterOutputStream { try { + ZonedDateTime now = ZonedDateTime.now(midnight.getZone()); RolloverFileOutputStream.this.setFile(); - RolloverFileOutputStream.this.scheduleNextRollover(); - RolloverFileOutputStream.this.removeOldFiles(); + RolloverFileOutputStream.this.scheduleNextRollover(now); + RolloverFileOutputStream.this.removeOldFiles(now); } catch(Throwable t) {