Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
776fd3e947
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue