Author: clebert.suconic(a)jboss.com
Date: 2011-12-05 16:19:58 -0500 (Mon, 05 Dec 2011)
New Revision: 11842
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java
Log:
JBPAPP-7455 - reverting accidental commit
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java 2011-12-05
21:17:25 UTC (rev 11841)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java 2011-12-05
21:19:58 UTC (rev 11842)
@@ -13,7 +13,6 @@
package org.hornetq.core.paging.impl;
-import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -116,9 +115,9 @@
ArrayList<PagedMessage> messages = new ArrayList<PagedMessage>();
size.set((int)file.size());
+ // Using direct buffer, as described on
https://jira.jboss.org/browse/HORNETQ-467
+ ByteBuffer buffer2 = ByteBuffer.allocateDirect(size.get());
- ByteBuffer buffer2 = allocateBuffer();
-
file.position(0);
file.read(buffer2);
@@ -176,38 +175,6 @@
return messages;
}
- /**
- * @return
- * @throws InterruptedException
- */
- private ByteBuffer allocateBuffer() throws InterruptedException
- {
- // Using direct buffer, as described on
https://jira.jboss.org/browse/HORNETQ-467
- ByteBuffer buffer2 = null;
- try
- {
- buffer2 = ByteBuffer.allocateDirect(size.get());
- }
- catch (OutOfMemoryError error)
- {
- // This is a workaround for the way the JDK will deal with native buffers.
- // the main portion is outside of the VM heap
- // and the JDK will not have any reference about it to take GC into account
- // so we force a GC and try again.
- WeakReference<Object> obj = new WeakReference<Object>(new
Object());
- long timeout = System.currentTimeMillis() + 5000;
- while (System.currentTimeMillis() > timeout && obj.get() != null)
- {
- System.gc();
- Thread.sleep(100);
- }
-
- buffer2 = ByteBuffer.allocateDirect(size.get());
-
- }
- return buffer2;
- }
-
public void write(final PagedMessage message) throws Exception
{
ByteBuffer buffer = fileFactory.newBuffer(message.getEncodeSize() +
PageImpl.SIZE_RECORD);