You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by sh...@apache.org on 2005/07/23 15:23:35 UTC
svn commit: r224462 -
/excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java
Author: shash
Date: Sat Jul 23 06:23:24 2005
New Revision: 224462
URL: http://svn.apache.org/viewcvs?rev=224462&view=rev
Log:
Fix for AVALON-7
Calculate where the oldest file is in the array of files, don';t assume it is always at index 0
Modified:
excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java
Modified: excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java?rev=224462&r1=224461&r2=224462&view=diff
==============================================================================
--- excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java (original)
+++ excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java Sat Jul 23 06:23:24 2005
@@ -152,7 +152,7 @@
final int[] rotations = calculateRotations( matchingFiles );
- //First we go through and look for maximumRotation
+ //First we go through and look for maximum rotation
int maxRotation = 0;
for( int i = 0; i < rotations.length; i++ )
{
@@ -163,6 +163,19 @@
}
}
+ //Now that we know maximum rotation, find minimum rotation, and index in array
+ int minRotation = maxRotation; //don't assume min is 0
+ int minRotationIndex = 0; //not correct now, but we will set in the loop below
+ for( int i = 0; i < rotations.length; i++ )
+ {
+ final int rotation = rotations[ i ];
+ if (rotation <= minRotation)
+ {
+ minRotation = rotation;
+ minRotationIndex = i;
+ }
+ }
+
//If the max rotation present on filessytem
//is less than max rotation possible then return that
//rotation
@@ -172,10 +185,10 @@
}
//Okay now we need to calculate the youngest file for our rotation
- long time = matchingFiles[ 0 ].lastModified();
+ long time = matchingFiles[ minRotationIndex ].lastModified();
//index of oldest file
- int oldest = rotations[ 0 ];
+ int oldest = rotations[ minRotationIndex ];
for( int i = 0; i < matchingFiles.length; i++ )
{
final File file = matchingFiles[ i ];
---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org