Buggy code:
public void setComparatorsByPosition ( List < String > comparatorsByPosition ) { } public void setComparatorsByPosition ( String ... comparators ) { } public void setComparatorByPosition ( int index , String c ) { } @ Override public int compareTo ( AbstractComposite o ) { } private String comparatorForSerializer ( Serializer < ? > s ) { } private Serializer < ? > serializerForComparator ( String c ) { } private Serializer < ? > serializerForPosition ( int i ) { } private Serializer < ? > getSerializer ( int i , String c ) { } private String comparatorForPosition ( int i ) { } private String getComparator ( int i , ByteBuffer bb ) { } @ Override public void clear ( ) { } @ Override public int size ( ) { } public < T > AbstractComposite addComponent ( T value , Serializer < T > s ) { } public < T > AbstractComposite addComponent ( T value , Serializer < T > s , String comparator ) { } public < T > AbstractComposite addComponent ( T value , Serializer < T > s , String comparator , AbstractComposite . ComponentEquality equality ) { } @ SuppressWarnings ( "unchecked" ) public < T > AbstractComposite addComponent ( int index , T value , Serializer < T > s , String comparator , AbstractComposite . ComponentEquality equality ) { } private static Object mapIfNumber ( Object o ) { } @ SuppressWarnings ( { "unchecked" } ) private static Collection < ? > flatten ( Collection < ? > c ) { } @ Override public boolean addAll ( Collection < ? extends Object > c ) { } @ Override public boolean containsAll ( Collection < ? > c ) { } @ Override public boolean removeAll ( Collection < ? > c ) { } @ Override public boolean retainAll ( Collection < ? > c ) { } @ Override public boolean addAll ( int i , Collection < ? extends Object > c ) { } @ SuppressWarnings ( "unchecked" ) @ Override public void add ( int index , Object element ) { } @ Override public Object remove ( int index ) { } public < T > AbstractComposite setComponent ( int index , T value , Serializer < T > s ) { } public < T > AbstractComposite setComponent ( int index , T value , Serializer < T > s , String comparator ) { } @ SuppressWarnings ( "unchecked" ) public < T > AbstractComposite setComponent ( int index , T value , Serializer < T > s , String comparator , AbstractComposite . ComponentEquality equality ) { } @ SuppressWarnings ( "unchecked" ) @ Override public Object set ( int index , Object element ) { } @ Override public Object get ( int i ) { } public < T > T get ( int i , Serializer < T > s ) throws ClassCastException { } public AbstractComposite . Component getComponent ( int i ) { } public Iterator < AbstractComposite . Component < ? > > componentsIterator ( ) { } @ SuppressWarnings ( "unchecked" ) public ByteBuffer serialize ( ) { if ( ( serialized ) != null ) { return serialized . duplicate ( ) ; } ByteBufferOutputStream out = new ByteBufferOutputStream ( ) ; int i = 0 ; for ( AbstractComposite . Component c : components ) { Serializer < ? > s = serializerForPosition ( i ) ; ByteBuffer cb = c . getBytes ( s ) ; if ( cb == null ) { cb = ByteBuffer . allocate ( 0 ) ; } if ( dynamic ) { String comparator = comparatorForPosition ( i ) ; if ( comparator == null ) { comparator = c . getComparator ( ) ; } if ( comparator == null ) { comparator = BYTESTYPE . getTypeName ( ) ; } int p = comparator . indexOf ( "(reversed=true)" ) ; boolean desc = false ; if ( p >= 0 ) { comparator = comparator . substring ( 0 , p ) ; desc = true ; } if ( aliasToComparatorMapping . inverse ( ) . containsKey ( comparator ) ) { byte a = aliasToComparatorMapping . inverse ( ) . get ( comparator ) ; if ( desc ) { a = ( ( byte ) ( Character . toUpperCase ( ( ( char ) ( a ) ) ) ) ) ; } out . writeShort ( ( ( short ) ( 32768 | a ) ) ) ; } else { out . writeShort ( ( ( short ) ( comparator . length ( ) ) ) ) ; <START_BUG> out . write ( ByteBuffer . wrap ( comparator . getBytes ( Charsets . UTF_8 ) ) ) ; <END_BUG> } } out . writeShort ( ( ( short ) ( cb . remaining ( ) ) ) ) ; out . write ( cb . slice ( ) ) ; if ( ( i == ( ( components . size ( ) ) - 1 ) ) && ( ( equality ) != ( AbstractComposite . ComponentEquality . EQUAL ) ) ) { out . write ( equality . toByte ( ) ) ; } else { out . write ( c . getEquality ( ) . toByte ( ) ) ; } i ++ ; } serialized = out . getByteBuffer ( ) ; return serialized . duplicate ( ) ; } @ SuppressWarnings ( "unchecked" ) public void deserialize ( ByteBuffer b ) { } protected static int getShortLength ( ByteBuffer bb ) { } protected static ByteBuffer getBytes ( ByteBuffer bb , int length ) { } protected static ByteBuffer getWithShortLength ( ByteBuffer bb ) { } public AbstractComposite . ComponentEquality getEquality ( ) { } public void setEquality ( AbstractComposite . ComponentEquality equality ) { } }

Fix:
out . write ( comparator . getBytes ( Charsets . UTF_8 ) ) ;