Issue #1507
This commit is contained in:
parent
8af0d153e0
commit
118652e985
|
@ -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