-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4
-
Component/s: None
-
None
-
Environment:Java
-
Major Change
The ByteEncoder class assumes that if a value isArray(), the array type is Object. This throws a ClassCastException if you attempt to pass a primitive array:
else if ( val.getClass().isArray() )
putList( name , Arrays.asList( (Object[])val ) );
It would be more flexible to use Array.get() to reflectively read the array:
private void putArray( String name , Object array )
{ _put( ARRAY , name ); final int sizePos = _buf.position(); _buf.putInt( 0 ); int size = Array.getLength(array); for ( int i=0; i<size; i++ ) _putObjectField( String.valueOf( i ) , Array.get( array, i ) ); _buf.put( EOO ); _buf.putInt( sizePos , _buf.position() - sizePos ); }I can provide a patch, if needed.