Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x

This commit is contained in:
Joakim Erdfelt 2017-04-13 09:07:58 -07:00
commit 68ff657c0b
1 changed files with 8 additions and 9 deletions

View File

@ -175,8 +175,6 @@ public class RolloverFileOutputStream extends FilterOutputStream
if (__rollover==null) if (__rollover==null)
__rollover=new Timer(RolloverFileOutputStream.class.getName(),true); __rollover=new Timer(RolloverFileOutputStream.class.getName(),true);
_rollTask=new RollTask();
midnight = toMidnight(ZonedDateTime.now(), zone.toZoneId()); midnight = toMidnight(ZonedDateTime.now(), zone.toZoneId());
scheduleNextRollover(); scheduleNextRollover();
@ -204,14 +202,12 @@ public class RolloverFileOutputStream extends FilterOutputStream
public static ZonedDateTime nextMidnight(ZonedDateTime dateTime) public static ZonedDateTime nextMidnight(ZonedDateTime dateTime)
{ {
// Increment to next day. // 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()); return dateTime.toLocalDate().plus(1, ChronoUnit.DAYS).atStartOfDay(dateTime.getZone());
} }
private void scheduleNextRollover() private void scheduleNextRollover()
{ {
_rollTask = new RollTask();
midnight = nextMidnight(midnight); midnight = nextMidnight(midnight);
__rollover.schedule(_rollTask,midnight.toInstant().toEpochMilli() - System.currentTimeMillis()); __rollover.schedule(_rollTask,midnight.toInstant().toEpochMilli() - System.currentTimeMillis());
} }
@ -343,7 +339,10 @@ public class RolloverFileOutputStream extends FilterOutputStream
_file=null; _file=null;
} }
_rollTask.cancel(); if (_rollTask != null)
{
_rollTask.cancel();
}
} }
} }
@ -359,10 +358,10 @@ public class RolloverFileOutputStream extends FilterOutputStream
RolloverFileOutputStream.this.scheduleNextRollover(); RolloverFileOutputStream.this.scheduleNextRollover();
RolloverFileOutputStream.this.removeOldFiles(); RolloverFileOutputStream.this.removeOldFiles();
} }
catch(IOException e) catch(Throwable t)
{ {
// Cannot log this exception to a LOG, as RolloverFOS can be used by logging // Cannot log this exception to a LOG, as RolloverFOS can be used by logging
e.printStackTrace(System.err); t.printStackTrace(System.err);
} }
} }
} }