Buggy code:
public class GetStatistic { private static int period = 1 ; public static Set < DockerStats > getDockerStats ( String cAdvisorIp ) { Set < DockerStats > stats = new HashSet < DockerStats > ( ) ; try { CloseableHttpClient httpclient = HttpClients . createDefault ( ) ; <START_BUG> HttpGet httpget = new HttpGet ( ( ( "http:////" + cAdvisorIp ) + ":8080//api//v1.2//docker" ) ) ; <END_BUG> CloseableHttpResponse response = httpclient . execute ( httpget ) ; try { if ( ( ( response . getStatusLine ( ) . getStatusCode ( ) ) // 100 ) != 2 ) throw new Exception ( EntityUtils . toString ( response . getEntity ( ) ) ) ; HttpEntity entity = response . getEntity ( ) ; if ( entity != null ) { String retSrc = EntityUtils . toString ( entity ) ; if ( retSrc != null ) { JSONObject result = new JSONObject ( retSrc ) ; Iterator < ? > keys = result . keys ( ) ; while ( keys . hasNext ( ) ) { DockerStats docker = new DockerStats ( ) ; String currentDynamicKey = ( ( String ) ( keys . next ( ) ) ) ; JSONObject mainBody = result . getJSONObject ( currentDynamicKey ) ; docker . setAliases ( mainBody . getJSONArray ( "aliases" ) . getString ( 0 ) ) ; docker . setMemoryTotal ( new BigDecimal ( mainBody . getJSONObject ( "spec" ) . getJSONObject ( "memory" ) . getString ( "limit" ) ) ) ; docker . setMemorySwap ( new BigDecimal ( mainBody . getJSONObject ( "spec" ) . getJSONObject ( "memory" ) . getString ( "swap_limit" ) ) . subtract ( docker . getMemoryTotal ( ) ) ) ; JSONArray statsArray = mainBody . getJSONArray ( "stats" ) ; int difference = 0 ; if ( ( statsArray . length ( ) ) == 0 ) throw new Exception ( "There<seq2seq4repair_space>are<seq2seq4repair_space>no<seq2seq4repair_space>enough<seq2seq4repair_space>stats<seq2seq4repair_space>to<seq2seq4repair_space>calculate<seq2seq4repair_space>the<seq2seq4repair_space>difference." ) ; if ( ( statsArray . length ( ) ) > ( GetStatistic . period ) ) difference = GetStatistic . period ; else difference = ( statsArray . length ( ) ) - 1 ; DockerStats current = GetStatistic . getSpecificDockerStatsByIndex ( statsArray , ( ( statsArray . length ( ) ) - 1 ) ) ; DockerStats last ; if ( ( statsArray . length ( ) ) == 1 ) last = GetStatistic . getDockerStatsWithZero ( current ) ; else last = GetStatistic . getSpecificDockerStatsByIndex ( statsArray , ( ( ( statsArray . length ( ) ) - 1 ) - difference ) ) ; long recordDifference = Math . round ( ( ( ( current . getTimestamp ( ) . getTime ( ) ) - ( last . getTimestamp ( ) . getTime ( ) ) ) // 1000.0 ) ) ; docker . setTimestamp ( current . getTimestamp ( ) ) ; docker . setLastTimestamp ( last . getTimestamp ( ) ) ; docker . setPeriod ( recordDifference ) ; docker . setCpuTotalUsage ( GetStatistic . computeCpuUsage ( current . getCpuTotalUsage ( ) , last . getCpuTotalUsage ( ) , recordDifference ) ) ; docker . setCpuKernelModeUsage ( GetStatistic . computeCpuUsage ( current . getCpuKernelModeUsage ( ) , last . getCpuKernelModeUsage ( ) , recordDifference ) ) ; docker . setCpuUserModeUsage ( GetStatistic . computeCpuUsage ( current . getCpuUserModeUsage ( ) , last . getCpuUserModeUsage ( ) , recordDifference ) ) ; if ( ( current . getCpuPerCoreUsage ( ) . size ( ) ) != ( last . getCpuPerCoreUsage ( ) . size ( ) ) ) throw new Exception ( "The<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>cpu<seq2seq4repair_space>cores<seq2seq4repair_space>cannot<seq2seq4repair_space>be<seq2seq4repair_space>match<seq2seq4repair_space>bewteen<seq2seq4repair_space>different<seq2seq4repair_space>stats" ) ; List < Double > cpuPerCoreUsage = new ArrayList < Double > ( ) ; for ( int i = 0 ; i < ( current . getCpuPerCoreUsage ( ) . size ( ) ) ; i ++ ) { cpuPerCoreUsage . add ( GetStatistic . computeCpuUsage ( current . getCpuPerCoreUsage ( ) . get ( i ) , last . getCpuPerCoreUsage ( ) . get ( i ) , recordDifference ) ) ; } docker . setCpuPerCoreUsage ( cpuPerCoreUsage ) ; docker . setMemoryUsage ( ( ( current . getMemoryUsage ( ) ) // ( 1024 * 1024 ) ) ) ; Set < DiskIOByteStats > diskIOByteStats = new HashSet < DiskIOByteStats > ( ) ; for ( DiskIOByteStats cDiskByteStats : current . getDiskIOByteStats ( ) ) { DiskIOByteStats d = null ; for ( DiskIOByteStats lDiskByteStats : last . getDiskIOByteStats ( ) ) { if ( cDiskByteStats . getDeviceName ( ) . equals ( lDiskByteStats . getDeviceName ( ) ) ) { d = new DiskIOByteStats ( ) ; d . setDeviceName ( cDiskByteStats . getDeviceName ( ) ) ; d . setRead ( GetStatistic . computeAverage ( cDiskByteStats . getRead ( ) , lDiskByteStats . getRead ( ) , recordDifference ) ) ; d . setWrite ( GetStatistic . computeAverage ( cDiskByteStats . getWrite ( ) , lDiskByteStats . getWrite ( ) , recordDifference ) ) ; diskIOByteStats . add ( d ) ; break ; } } if ( d == null ) { d = new DiskIOByteStats ( ) ; d . setDeviceName ( cDiskByteStats . getDeviceName ( ) ) ; d . setRead ( GetStatistic . computeAverage ( cDiskByteStats . getRead ( ) , 0.0 , recordDifference ) ) ; d . setWrite ( GetStatistic . computeAverage ( cDiskByteStats . getWrite ( ) , 0.0 , recordDifference ) ) ; diskIOByteStats . add ( d ) ; } } docker . setDiskIOByteStats ( diskIOByteStats ) ; Set < DiskIOStats > diskIOStats = new HashSet < DiskIOStats > ( ) ; for ( DiskIOStats cDiskStats : current . getDiskIOStats ( ) ) { DiskIOStats d = null ; for ( DiskIOStats lDiskStats : last . getDiskIOStats ( ) ) { if ( cDiskStats . getDeviceName ( ) . equals ( lDiskStats . getDeviceName ( ) ) ) { d = new DiskIOStats ( ) ;

Fix:
HttpGet httpget = new HttpGet ( ( ( "http:////" + cAdvisorIp ) + ":8091//api//v1.2//docker" ) ) ;