### Question:
AvlTreeMarshaller implements Marshaller<AvlTree<E>> { public AvlTree<E> deserialize( byte[] data ) throws IOException { if ( data == null || data.length == 0 ) { throw new IOException( I18n.err( I18n.ERR_439 ) ); } if ( data.length == 1 && data[0] == 0 ) { return new AvlTreeImpl<>( comparator ); } ByteArrayInputStream bin = new ByteArrayInputStream( data ); DataInputStream din = new DataInputStream( bin ); byte startByte = din.readByte(); if ( startByte != 0 ) { throw new IOException( I18n.err( I18n.ERR_443 ) ); } int size = din.readInt(); LinkedAvlNode[] nodes = new LinkedAvlNode[size]; LinkedAvlNode<E> root = readTree( din, nodes ); AvlTreeImpl<E> tree = new AvlTreeImpl<>( comparator ); tree.setRoot( root ); tree.setFirst( nodes[0] ); tree.setSize( size ); if ( nodes.length >= 1 ) { tree.setLast( nodes[nodes.length - 1] ); } for ( int i = 0; i < nodes.length - 1; i++ ) { nodes[i].setNext( nodes[i + 1] ); nodes[i + 1].setPrevious( nodes[i] ); } return tree; } AvlTreeMarshaller( Comparator<E> comparator, Marshaller<E> keyMarshaller );  AvlTreeMarshaller( Comparator<E> comparator ); byte[] serialize( AvlTree<E> tree ); AvlTree<E> deserialize( byte[] data ); LinkedAvlNode<E> readTree( DataInputStream in, LinkedAvlNode[] nodes );  }### Answer:
@Test public void testRemoveBug() throws IOException { Comparator<Long> comparator = new Comparator<Long>() { public int compare( Long i1, Long i2 ) { return i1.compareTo( i2 ); } }; AvlTreeMarshaller<Long> treeMarshaller = new AvlTreeMarshaller<Long>( comparator, new LongMarshaller() ); AvlTree<Long> tree = treeMarshaller.deserialize( SERIALIZED_AVLTREE_PRE_REMOVE ); for ( long key : AVLTREE_KEYS_PRE_REMOVE ) { assertNotNull( "Should find " + key, tree.find( key ) ); } tree.remove( 110L ); for ( long key : AVLTREE_EXPECTED_KEYS_POST_REMOVE ) { assertNotNull( "Should find " + key, tree.find( key ) ); } }
@Test(expected = IOException.class) public void testDeserializeNullData() throws IOException { AvlTreeMarshaller<Integer> treeMarshaller = createTreeMarshaller(); treeMarshaller.deserialize( null ); }