Buggy code:
public class HttpPostGenerator { public static HttpPost genPost ( ) { } public static HttpPost genPost ( TestResult data ) { File mainStorageDir = MainStorage . getMainStorageDirectory ( ) ; String uid = PreferenceControl . getUID ( ) ; String deviceId = PreferenceControl . getDeviceId ( ) ; HttpPost httpPost = new HttpPost ( ServerUrl . getTestResultUrl ( ) ) ; MultipartEntityBuilder builder = MultipartEntityBuilder . create ( ) ; builder . addTextBody ( "uid" , uid ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . tv . getTimestamp ( ) ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( deviceId ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . result ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . cassette_id ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . isPrime ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . isFilled ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . getScore ( ) ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( data . getTv ( ) . getWeek ( ) ) ) ; String _ts = String . valueOf ( data . tv . getTimestamp ( ) ) ; File [ ] imageFiles ; File [ ] picFiles ; File testFile ; File detectionFile ; int fileNum = new File ( ( ( ( ( mainStorageDir . getPath ( ) ) + ( File . separator ) ) + _ts ) + ( File . separator ) ) ) . listFiles ( ) . length ; Log . d ( "FileNum:<seq2seq4repair_space>" , ( ( _ts + "<seq2seq4repair_space>Num:<seq2seq4repair_space>" ) + fileNum ) ) ; builder . addTextBody ( "data[]" , String . valueOf ( fileNum ) ) ; imageFiles = new File [ fileNum ] ; <START_BUG> picFiles = new File [ 3 ] ; <END_BUG> testFile = new File ( ( ( ( ( ( mainStorageDir . getPath ( ) ) + ( File . separator ) ) + _ts ) + ( File . separator ) ) + "voltage.txt" ) ) ; detectionFile = new File ( ( ( ( ( ( mainStorageDir . getPath ( ) ) + ( File . separator ) ) + _ts ) + ( File . separator ) ) + "color_raw.txt" ) ) ; for ( int i = 0 ; i < ( imageFiles . length ) ; ++ i ) imageFiles [ i ] = new File ( ( ( ( ( ( ( ( ( ( mainStorageDir . getPath ( ) ) + ( File . separator ) ) + _ts ) + ( File . separator ) ) + "IMG_" ) + _ts ) + "_" ) + ( i + 1 ) ) + ".sob" ) ) ; for ( int i = 0 ; i < ( picFiles . length ) ; ++ i ) picFiles [ i ] = new File ( ( ( ( ( ( ( ( ( ( mainStorageDir . getPath ( ) ) + ( File . separator ) ) + _ts ) + ( File . separator ) ) + "PIC_" ) + _ts ) + "_" ) + i ) + ".sob" ) ) ; if ( testFile . exists ( ) ) builder . addPart ( "file[]" , new FileBody ( testFile ) ) ; if ( detectionFile . exists ( ) ) builder . addPart ( "file[]" , new FileBody ( detectionFile ) ) ; for ( int i = 0 ; i < ( imageFiles . length ) ; ++ i ) if ( imageFiles [ i ] . exists ( ) ) { builder . addPart ( "file[]" , new FileBody ( imageFiles [ i ] ) ) ; Log . d ( "image" , imageFiles [ i ] . getName ( ) ) ; } for ( int i = 0 ; i < ( picFiles . length ) ; ++ i ) if ( picFiles [ i ] . exists ( ) ) { builder . addPart ( "file[]" , new FileBody ( picFiles [ i ] ) ) ; Log . d ( "Pic" , picFiles [ i ] . getName ( ) ) ; } httpPost . setEntity ( builder . build ( ) ) ; return httpPost ; } public static HttpPost genPost ( NoteAdd data ) { } public static HttpPost genPost ( TestDetail data ) { } public static HttpPost genPost ( QuestionTest data ) { } public static HttpPost genPost ( CopingSkill data ) { } public static HttpPost genPost ( File logFile ) { } public static HttpPost genPost ( ExchangeHistory data ) { } }

Fix:
picFiles = new File [ fileNum ] ;