You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2007/10/15 14:03:23 UTC
svn commit: r584758 -
/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
Author: hindessm
Date: Mon Oct 15 05:03:22 2007
New Revision: 584758
URL: http://svn.apache.org/viewvc?rev=584758&view=rev
Log:
Make sure there are references to the ByteBuffers for as long as there
are references to the addresses in those buffers. Otherwise, "handles[]"
can be used after the RuntimeMemorySpy has free'd the memory that they
reference.
This fixes intermittent failures of the FileChannelTest
test_write$LByteBufferII(), where the first buffer was corrupted because
it has been free'd by the RuntimeMemorySpy during the alloc of the second.
Modified:
harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=584758&r1=584757&r2=584758&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java Mon Oct 15 05:03:22 2007
@@ -582,6 +582,7 @@
long[] handles = new long[length];
int[] offsets = new int[length];
int[] lengths = new int[length];
+ ByteBuffer[] bufferRefs = new ByteBuffer[length];
for (int i = 0; i < length; i++) {
ByteBuffer buffer = buffers[i + offset];
if (!buffer.isDirect()) {
@@ -596,6 +597,7 @@
}
handles[i] = ((DirectBuffer) buffer).getEffectiveAddress().toLong();
lengths[i] = buffer.remaining();
+ bufferRefs[i] = buffer;
}
long bytesWritten = 0;