Buggy code:
public class DirectCacheTest { static DirectCache directCache ; @ Test public void testGet ( ) throws Exception { } @ Test public void synchTest ( ) throws InterruptedException { } @ Test public void bitOperation ( ) { } @ Test public void put ( ) { DirectCacheTest . directCache = new DirectCache ( 3 ) ; long before = DirectCacheTest . directCache . getRemaining ( ) ; System . out . println ( DirectCacheTest . directCache . getRemaining ( ) ) ; <START_BUG> byte [ ] tab = new byte [ ] { 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 } ; <END_BUG> System . out . println ( tab . length ) ; int number = 10000000 ; long startPut = System . nanoTime ( ) ; for ( int i = 0 ; i < number ; i ++ ) DirectCacheTest . directCache . putOrUpdate ( i , tab ) ; long stopPut = System . nanoTime ( ) ; System . out . println ( ( ( ( ( "Avg<seq2seq4repair_space>put:" + ( ( stopPut - startPut ) // number ) ) + "<seq2seq4repair_space>Throughput:<seq2seq4repair_space>" ) + ( ( ( ( ( long ) ( number ) ) * ( ( long ) ( tab . length ) ) ) // ( 1024 * 1024 ) ) // ( TimeUnit . SECONDS . convert ( ( stopPut - startPut ) , TimeUnit . NANOSECONDS ) ) ) ) + "MB//s" ) ) ; byte [ ] tab2 = new byte [ ] { 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 18 } ; long test = 0 ; long start = System . nanoTime ( ) ; for ( int i = 0 ; i < number ; i ++ ) test += DirectCacheTest . directCache . get ( i ) . length ; long stop = System . nanoTime ( ) ; System . out . println ( ( ( ( ( "Avg<seq2seq4repair_space>get:" + ( ( stop - start ) // number ) ) + "<seq2seq4repair_space>Throughput:<seq2seq4repair_space>" ) + ( ( ( ( ( long ) ( number ) ) * ( ( long ) ( tab . length ) ) ) // ( 1024 * 1024 ) ) // ( TimeUnit . SECONDS . convert ( ( stop - start ) , TimeUnit . NANOSECONDS ) ) ) ) + "MB//s" ) ) ; System . out . println ( DirectCacheTest . directCache . getRemaining ( ) ) ; IntStream natural = IntStream . iterate ( 0 , ( i ) -> i + 1 ) ; natural . limit ( ( number + 1000 ) ) . filter ( ( i ) -> ( i % 7 ) == 0 ) . parallel ( ) . forEach ( ( i ) -> DirectCacheTest . directCache . putOrUpdate ( i , tab2 ) ) ; long after = DirectCacheTest . directCache . getRemaining ( ) ; System . out . println ( after ) ; assertTrue ( ( before > after ) ) ; start = System . nanoTime ( ) ; DirectCacheTest . directCache . compact ( ) ; stop = System . nanoTime ( ) ; System . out . println ( ( "Compact<seq2seq4repair_space>time<seq2seq4repair_space>:" + ( TimeUnit . MILLISECONDS . convert ( ( stop - start ) , TimeUnit . NANOSECONDS ) ) ) ) ; System . out . println ( DirectCacheTest . directCache . getRemaining ( ) ) ;

Fix:
byte [ ] tab = new byte [ ] { 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 0 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 , 1 , 18 , 17 , 18 } ;