From 38943644e07bf3efcc329a8bf41f9ce3312ee2fe Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 4 Oct 2012 02:41:04 +0000 Subject: [PATCH] HDFS-4000. TestParallelLocalRead fails with "input ByteBuffers must be direct buffers". Contributed by Colin Patrick McCabe git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1393884 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/hdfs/TestParallelReadUtil.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5930198fa8..f53261f912 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -276,6 +276,9 @@ Release 2.0.3-alpha - Unreleased HDFS-3753. Tests don't run with native libraries. (Colin Patrick McCabe via eli) + HDFS-4000. TestParallelLocalRead fails with "input ByteBuffers + must be direct buffers". (Colin Patrick McCabe via eli) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java index dacd4bca99..1c59eca871 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java @@ -83,7 +83,7 @@ static interface ReadWorkerHelper { static class DirectReadWorkerHelper implements ReadWorkerHelper { @Override public int read(DFSInputStream dis, byte[] target, int startOff, int len) throws IOException { - ByteBuffer bb = ByteBuffer.wrap(target); + ByteBuffer bb = ByteBuffer.allocateDirect(target.length); int cnt = 0; synchronized(dis) { dis.seek(startOff); @@ -95,6 +95,8 @@ public int read(DFSInputStream dis, byte[] target, int startOff, int len) throws cnt += read; } } + bb.clear(); + bb.get(target); return cnt; }