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)
__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());
}
@ -342,8 +338,11 @@ public class RolloverFileOutputStream extends FilterOutputStream
out=null;
_file=null;
}
_rollTask.cancel();
if (_rollTask != null)
{
_rollTask.cancel();
}
}
}
@ -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);
}
}
}