db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1103681 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/io/vfmem/BlockedByteArray.java
Date Mon, 16 May 2011 10:39:22 GMT
Author: kristwaa
Date: Mon May 16 10:39:22 2011
New Revision: 1103681

URL: http://svn.apache.org/viewvc?rev=1103681&view=rev
Log:
DERBY-5098: embedded/in-memory: SQLNonTransientConnectionException: No current connection
due to invalid page format

Fix int overflows.
The bug caused the in-memory backend to overwrite existing data when the
virtual file/conglomerate grew big enough.

Patch file: derby-5098-1a-overflow_fixes.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/io/vfmem/BlockedByteArray.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/vfmem/BlockedByteArray.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/vfmem/BlockedByteArray.java?rev=1103681&r1=1103680&r2=1103681&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/vfmem/BlockedByteArray.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/vfmem/BlockedByteArray.java Mon
May 16 10:39:22 2011
@@ -143,7 +143,7 @@ public class BlockedByteArray {
         if (blockSize == 0) {
             checkBlockSize((int)Math.min(Integer.MAX_VALUE, newLength));
         }
-        final long currentCapacity = allocatedBlocks * blockSize;
+        final long currentCapacity = (long)allocatedBlocks * blockSize;
         if (newLength > currentCapacity) {
             // Allocate more blocks.
             increaseCapacity(newLength);
@@ -187,7 +187,7 @@ public class BlockedByteArray {
             throw new ArrayIndexOutOfBoundsException(len);
         }
         // Increase the capacity if required.
-        if (pos + len >= allocatedBlocks * blockSize) {
+        if (pos + len >= (long)allocatedBlocks * blockSize) {
             increaseCapacity(pos + len);
         }
         // Calculate the block number and the index within this block.
@@ -226,7 +226,7 @@ public class BlockedByteArray {
             checkBlockSize(0);
         }
         // Increase the capacity if required.
-        if (pos >= allocatedBlocks * blockSize) {
+        if (pos >= (long)allocatedBlocks * blockSize) {
             increaseCapacity(pos);
         }
 
@@ -301,7 +301,7 @@ public class BlockedByteArray {
             SanityManager.ASSERT(blockSize > 0, "Invalid/unset block size");
         }
         // Safe-guard to avoid overwriting existing data.
-        if (lastIndex < allocatedBlocks * blockSize) {
+        if (lastIndex < (long)allocatedBlocks * blockSize) {
             return;
         }
         // Calculate required number of blocks, and create those lacking.



Mime
View raw message