Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
68ff657c0b
|
@ -175,8 +175,6 @@ public class RolloverFileOutputStream extends FilterOutputStream
|
|||
if (__rollover==null)
|
||||
__rollover=new Timer(RolloverFileOutputStream.class.getName(),true);
|
||||
|
||||
_rollTask=new RollTask();
|
||||
|
||||
midnight = toMidnight(ZonedDateTime.now(), zone.toZoneId());
|
||||
|
||||
scheduleNextRollover();
|
||||
|
@ -204,14 +202,12 @@ public class RolloverFileOutputStream extends FilterOutputStream
|
|||
public static ZonedDateTime nextMidnight(ZonedDateTime dateTime)
|
||||
{
|
||||
// Increment to next day.
|
||||
// Using Calendar.add(DAY, 1) takes in account Daylights Savings
|
||||
// differences, and still maintains the "midnight" settings for
|
||||
// Hour, Minute, Second, Milliseconds
|
||||
return dateTime.toLocalDate().plus(1, ChronoUnit.DAYS).atStartOfDay(dateTime.getZone());
|
||||
}
|
||||
|
||||
private void scheduleNextRollover()
|
||||
{
|
||||
_rollTask = new RollTask();
|
||||
midnight = nextMidnight(midnight);
|
||||
__rollover.schedule(_rollTask,midnight.toInstant().toEpochMilli() - System.currentTimeMillis());
|
||||
}
|
||||
|
@ -343,9 +339,12 @@ public class RolloverFileOutputStream extends FilterOutputStream
|
|||
_file=null;
|
||||
}
|
||||
|
||||
if (_rollTask != null)
|
||||
{
|
||||
_rollTask.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private class RollTask extends TimerTask
|
||||
|
@ -359,10 +358,10 @@ public class RolloverFileOutputStream extends FilterOutputStream
|
|||
RolloverFileOutputStream.this.scheduleNextRollover();
|
||||
RolloverFileOutputStream.this.removeOldFiles();
|
||||
}
|
||||
catch(IOException e)
|
||||
catch(Throwable t)
|
||||
{
|
||||
// Cannot log this exception to a LOG, as RolloverFOS can be used by logging
|
||||
e.printStackTrace(System.err);
|
||||
t.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue