commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1670666 - in /commons/proper/jcs/trunk/commons-jcs-core/src: main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDisk.java test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
Date Wed, 01 Apr 2015 15:15:25 GMT
Author: tv
Date: Wed Apr  1 15:15:24 2015
New Revision: 1670666

URL: http://svn.apache.org/r1670666
Log:
Fix JCS-146: IndexedDiskCache: Mismatched memory and disk length (0) for [DED:  pos = 63802
len = 9658] during optimization

Modified:
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDisk.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDisk.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDisk.java?rev=1670666&r1=1670665&r2=1670666&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDisk.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDisk.java
Wed Apr  1 15:15:24 2015
@@ -151,6 +151,7 @@ class IndexedDisk
         {
             // chunk it
             int chunkSize = Math.min( remaining, buffer.capacity() );
+            buffer.limit(chunkSize);
             fc.read(buffer, readPos);
             buffer.flip();
             fc.write(buffer, writePos);

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java?rev=1670666&r1=1670665&r2=1670666&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
Wed Apr  1 15:15:24 2015
@@ -42,10 +42,10 @@ public class IndexedDiskCacheOptimizatio
     {
         // SETUP
         int removeCount = 50;
-
+        
         IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
         cattr.setCacheName( "testOptimization" );
-        cattr.setMaxKeySize( removeCount * 3 );
+        cattr.setMaxKeySize( removeCount * 2 );
         cattr.setOptimizeAtRemoveCount( removeCount );
         cattr.setMaxRecycleBinSize( removeCount * 3 );
         cattr.setDiskPath( "target/test-sandbox/testOptimization" );
@@ -53,7 +53,7 @@ public class IndexedDiskCacheOptimizatio
 
         disk.removeAll();
 
-        int numberToInsert = removeCount * 2;
+        int numberToInsert = removeCount * 3;
         ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil
             .createCacheElementsWithTestObjectsOfVariableSizes( numberToInsert, cattr.getCacheName()
);
 
@@ -61,6 +61,7 @@ public class IndexedDiskCacheOptimizatio
         {
             disk.processUpdate( elements[i] );
         }
+                
 
         Thread.sleep( 1000 );
         long sizeBeforeRemove = disk.getDataFileSize();
@@ -72,9 +73,10 @@ public class IndexedDiskCacheOptimizatio
         {
             disk.processRemove( Integer.valueOf( i ) );
         }
-
+        
         SleepUtil.sleepAtLeast( 1000 );
 
+        disk.optimizeFile();
         // VERIFY
         long sizeAfterRemove = disk.getDataFileSize();
         long expectedSizeAfterRemove = DiskTestObjectUtil.totalSize( elements, removeCount,
elements.length );



Mime
View raw message