You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2009/04/15 00:15:14 UTC
svn commit: r764983 - in /hadoop/avro/trunk: CHANGES.txt
src/java/org/apache/avro/ipc/ByteBufferInputStream.java
src/test/java/org/apache/avro/TestProtocolSpecific.java
Author: cutting
Date: Tue Apr 14 22:15:14 2009
New Revision: 764983
URL: http://svn.apache.org/viewvc?rev=764983&view=rev
Log:
Fix so that EOF is not thrown when one attempts to read an empty buffer. Contributed by sharad.
Modified:
hadoop/avro/trunk/CHANGES.txt
hadoop/avro/trunk/src/java/org/apache/avro/ipc/ByteBufferInputStream.java
hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java
Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=764983&r1=764982&r2=764983&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Apr 14 22:15:14 2009
@@ -21,3 +21,6 @@
AVRO-4. Fix so that specific code generation works under Eclipse.
(Pat Hunt via cutting)
+
+ AVRO-14. Fix so that EOF is not thrown when one attempts to read
+ an empty buffer. (sharad via cutting)
Modified: hadoop/avro/trunk/src/java/org/apache/avro/ipc/ByteBufferInputStream.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/ipc/ByteBufferInputStream.java?rev=764983&r1=764982&r2=764983&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/ipc/ByteBufferInputStream.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/ipc/ByteBufferInputStream.java Tue Apr 14 22:15:14 2009
@@ -42,6 +42,7 @@
/** @see InputStream#read(byte[], int, int)
* @throws EOFException if EOF is reached before reading all the bytes. */
public int read(byte b[], int off, int len) throws IOException {
+ if (len == 0) return 0;
ByteBuffer buffer = getBuffer();
int remaining = buffer.remaining();
if (len > remaining) {
@@ -56,6 +57,7 @@
/** Read a buffer from the input without copying, if possible.
* @throws EOFException if EOF is reached before reading all the bytes. */
public ByteBuffer readBuffer(int length) throws IOException {
+ if (length == 0) return ByteBuffer.allocate(0);
ByteBuffer buffer = getBuffer();
if (buffer.remaining() == length) { // can return current as-is?
current++;
Modified: hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java?rev=764983&r1=764982&r2=764983&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java (original)
+++ hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java Tue Apr 14 22:15:14 2009
@@ -96,6 +96,13 @@
assertEquals(data, echoed);
}
+ public void testEmptyEchoBytes() throws IOException {
+ ByteBuffer data = ByteBuffer.allocate(0);
+ ByteBuffer echoed = proxy.echoBytes(data);
+ data.flip();
+ assertEquals(data, echoed);
+ }
+
public void testError() throws IOException {
TestError error = null;
try {