Based on current usage within Tomcat, message length of 0 should result in null.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 5 Jul 2011 12:25:38 +0000 (12:25 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 5 Jul 2011 12:25:38 +0000 (12:25 +0000)
Populate the test for this and ensure the test passes.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1143022 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/tribes/io/XByteBuffer.java
test/org/apache/catalina/tribes/io/TestXByteBuffer.java

index 71f2d63..b35bd10 100644 (file)
@@ -561,7 +561,7 @@ public class XByteBuffer
         invokecount.addAndGet(1);
         Object message = null;
         if ( cls == null ) cls = new ClassLoader[0];
-        if (data != null) {
+        if (data != null && length > 0) {
             InputStream  instream = new ByteArrayInputStream(data,offset,length);
             ObjectInputStream stream = null;
             stream = (cls.length>0)? new ReplicationStream(instream,cls):new ObjectInputStream(instream);
index 9cb09fd..5f2917b 100644 (file)
@@ -21,7 +21,8 @@ import junit.framework.TestCase;
 public class TestXByteBuffer extends TestCase {
 
     public void testEmptyArray() throws Exception {
-        // TODO
+        Object obj = XByteBuffer.deserialize(new byte[0]);
+        assertNull(obj);
     }
 
     public void testSerializationString() throws Exception {