diff --git a/src/org/jgroups/BytesMessage.java b/src/org/jgroups/BytesMessage.java index 67e970919f..685ddaf0d7 100644 --- a/src/org/jgroups/BytesMessage.java +++ b/src/org/jgroups/BytesMessage.java @@ -165,6 +165,15 @@ public BytesMessage setArray(ByteArray buf) { return this; } + public byte[] getBytes() { + if(array == null) return null; + if(offset == 0 && length == array.length) + return array; + byte[] tmp=new byte[length]; + System.arraycopy(array, offset, tmp, 0, length); + return tmp; + } + /** @@ -219,7 +228,7 @@ public T getObject(ClassLoader loader) { if(array == null) return null; try { - return isFlagSet(Flag.SERIALIZED)? Util.objectFromByteBuffer(array, offset, length, loader) : (T)getArray(); + return isFlagSet(Flag.SERIALIZED)? Util.objectFromByteBuffer(array, offset, length, loader) : (T)getBytes(); } catch(Exception ex) { throw new IllegalArgumentException(ex);