JCS-156 BlockDiskCache is limited to 2GB
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/jcs/trunk@1748248 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java
index 1ba89a8..5c7a7fa 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java
@@ -210,7 +210,7 @@
ByteBuffer dataBuffer = ByteBuffer.wrap(data, offset, length);
- long position = calculateByteOffsetForBlock(blocks[i]);
+ long position = calculateByteOffsetForBlockAsLong(blocks[i]);
// write the header
headerBuffer.flip();
int written = fc.write(headerBuffer, position);
@@ -323,7 +323,7 @@
boolean corrupted = false;
long fileLength = fc.size();
- int position = calculateByteOffsetForBlock( block );
+ long position = calculateByteOffsetForBlockAsLong( block );
// if ( position > fileLength )
// {
// corrupted = true;
@@ -374,15 +374,29 @@
/**
* Calculates the file offset for a particular block.
* <p>
- * @param block
- * @return the offset for this block
+ * @param block number
+ * @return the byte offset for this block in the file as an int; may overflow
+ * @deprecacted (since 2.0) use {@link #calculateByteOffsetForBlockAsLong(int)} instead
*/
+ @Deprecated
protected int calculateByteOffsetForBlock( int block )
{
return block * blockSizeBytes;
}
/**
+ * Calculates the file offset for a particular block.
+ * <p>
+ * @param block number
+ * @return the byte offset for this block in the file as a long
+ * @since 2.0
+ */
+ protected long calculateByteOffsetForBlockAsLong( int block )
+ {
+ return block * blockSizeBytes;
+ }
+
+ /**
* The number of blocks needed.
* <p>
* @param data
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6823b83..984cc77 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -20,6 +20,9 @@
</properties>
<body>
<release version="2.0" date="unreleased" description="JDK 1.6 based major release">
+ <action issue="JCS-156" dev="sebb" type="fix" due-to="Ryan Fong">
+ BlockDiskCache is limited to 2GB
+ </action>
<action issue="JCS-162" dev="tv" type="fix" due-to="Ryan Fong">
Fix: Memory region properties documentation incorrect
</action>