"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

TimeBasedTriggeringPolicy.java  (apache-log4j-2.11.1-src):TimeBasedTriggeringPolicy.java  (apache-log4j-2.11.2-src)
skipping to change at line 110 skipping to change at line 110
return nextRolloverMillis; return nextRolloverMillis;
} }
/** /**
* Initializes the policy. * Initializes the policy.
* @param aManager The RollingFileManager. * @param aManager The RollingFileManager.
*/ */
@Override @Override
public void initialize(final RollingFileManager aManager) { public void initialize(final RollingFileManager aManager) {
this.manager = aManager; this.manager = aManager;
long current = aManager.getFileTime();
if (current == 0) {
current = System.currentTimeMillis();
}
// LOG4J2-531: call getNextTime twice to force initialization of both pr evFileTime and nextFileTime // LOG4J2-531: call getNextTime twice to force initialization of both pr evFileTime and nextFileTime
aManager.getPatternProcessor().getNextTime(aManager.getFileTime(), inter val, modulate); aManager.getPatternProcessor().getNextTime(current, interval, modulate);
nextRolloverMillis = ThreadLocalRandom.current().nextLong(0, 1 + maxRand omDelayMillis) nextRolloverMillis = ThreadLocalRandom.current().nextLong(0, 1 + maxRand omDelayMillis)
+ aManager.getPatternProcessor().getNextTime(aManager.getFileTim e(), interval, modulate); + aManager.getPatternProcessor().getNextTime(current, interval, modulate);
} }
/** /**
* Determines whether a rollover should occur. * Determines whether a rollover should occur.
* @param event A reference to the currently event. * @param event A reference to the currently event.
* @return true if a rollover should occur. * @return true if a rollover should occur.
*/ */
@Override @Override
public boolean isTriggeringEvent(final LogEvent event) { public boolean isTriggeringEvent(final LogEvent event) {
if (manager.getFileSize() == 0) {
return false;
}
final long nowMillis = event.getTimeMillis(); final long nowMillis = event.getTimeMillis();
if (nowMillis >= nextRolloverMillis) { if (nowMillis >= nextRolloverMillis) {
nextRolloverMillis = ThreadLocalRandom.current().nextLong(0, 1 + max RandomDelayMillis) nextRolloverMillis = ThreadLocalRandom.current().nextLong(0, 1 + max RandomDelayMillis)
+ manager.getPatternProcessor().getNextTime(nowMillis, inter val, modulate); + manager.getPatternProcessor().getNextTime(nowMillis, inter val, modulate);
manager.getPatternProcessor().setCurrentFileTime(System.currentTimeM illis());
return true; return true;
} }
return false; return false;
} }
/** /**
* Creates a TimeBasedTriggeringPolicy. * Creates a TimeBasedTriggeringPolicy.
* @param interval The interval between rollovers. * @param interval The interval between rollovers.
* @param modulate If true the time will be rounded to occur on a boundary a ligned with the increment. * @param modulate If true the time will be rounded to occur on a boundary a ligned with the increment.
* @return a TimeBasedTriggeringPolicy. * @return a TimeBasedTriggeringPolicy.
 End of changes. 5 change blocks. 
5 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)