From: markt Date: Tue, 5 Jul 2011 12:25:38 +0000 (+0000) Subject: Based on current usage within Tomcat, message length of 0 should result in null. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1b2dff424d8cd9507e455b06484c15c803d16e76;p=tomcat7.0 Based on current usage within Tomcat, message length of 0 should result in null. 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 --- diff --git a/java/org/apache/catalina/tribes/io/XByteBuffer.java b/java/org/apache/catalina/tribes/io/XByteBuffer.java index 71f2d6331..b35bd10d7 100644 --- a/java/org/apache/catalina/tribes/io/XByteBuffer.java +++ b/java/org/apache/catalina/tribes/io/XByteBuffer.java @@ -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); diff --git a/test/org/apache/catalina/tribes/io/TestXByteBuffer.java b/test/org/apache/catalina/tribes/io/TestXByteBuffer.java index 9cb09fd38..5f2917bf6 100644 --- a/test/org/apache/catalina/tribes/io/TestXByteBuffer.java +++ b/test/org/apache/catalina/tribes/io/TestXByteBuffer.java @@ -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 {