Buggy code:
public class MongoDBDataUpload { private ArrayList < DBObject > mongoOperation = new ArrayList < DBObject > ( ) ; private List < SDPBulkInsertException > formalErrors = new ArrayList < SDPBulkInsertException > ( ) ; public MongoDBDataUpload ( ) { } public List < SDPBulkInsertException > checkFileToWrite ( String datiIn , String separator , Metadata datasetMetadata , boolean skipFirstRow ) { } public BulkWriteResult writeFileToMongo ( MongoClient mongoClient , String db , String dbcollection , Metadata datasetMetadata ) throws Exception { } public int getTotalDocumentToInsert ( ) { } private void prepareDataInsert ( String dataIn , String separator , Metadata datasetMetadata , boolean skipFirstRow ) throws IOException { ArrayList < SDPBulkInsertException > errors = new ArrayList < SDPBulkInsertException > ( ) ; ArrayList < DBObject > operations = new ArrayList < DBObject > ( ) ; char separatorChar = separator . charAt ( 0 ) ; CSVReader reader = new CSVReader ( new StringReader ( dataIn ) , separatorChar ) ; int numColumnFileIn = 0 ; String [ ] nextRow ; int lineNumber = 0 ; while ( ( nextRow = reader . readNext ( ) ) != null ) { lineNumber ++ ; System . out . println ( ( "Line<seq2seq4repair_space>#<seq2seq4repair_space>" + lineNumber ) ) ; GeoPoint geoPoint = new GeoPoint ( ) ; String [ ] fieldValues = nextRow ; String row = Util . join ( nextRow , "," ) ; if ( lineNumber == 1 ) { numColumnFileIn = fieldValues . length ; if ( skipFirstRow ) continue ; } if ( ( fieldValues . length ) != numColumnFileIn ) { SDPBulkInsertException curErr = new SDPBulkInsertException ( SDPBulkInsertException . ERROR_TYPE_TOTALFIELDINROW , row , lineNumber , ( - 1 ) , ( ( ( "Expected<seq2seq4repair_space>" + numColumnFileIn ) + "<seq2seq4repair_space>columns,<seq2seq4repair_space>found<seq2seq4repair_space>" ) + ( fieldValues . length ) ) ) ; errors . add ( curErr ) ; } BasicDBObjectBuilder builder = BasicDBObjectBuilder . start ( ) ; System . out . println ( ( "start<seq2seq4repair_space>..<seq2seq4repair_space>is<seq2seq4repair_space>empty<seq2seq4repair_space>--><seq2seq4repair_space>" + ( builder . isEmpty ( ) ) ) ) ; ArrayList < SDPBulkInsertException > errorCurrentRow = new ArrayList < SDPBulkInsertException > ( ) ; for ( int j = 0 ; ( ( datasetMetadata . getInfo ( ) . getFields ( ) ) != null ) && ( j < ( datasetMetadata . getInfo ( ) . getFields ( ) . length ) ) ; j ++ ) { int numColumn = 0 ; boolean found = false ; while ( ( ( fieldValues != null ) && ( numColumn < ( fieldValues . length ) ) ) && ( ! found ) ) { String typeCode = null ; String fieldName = null ; DateFormat formatter = Constants . DEFAULT_FIELD_DATE_FORMAT ; if ( ( datasetMetadata . getInfo ( ) . getFields ( ) [ j ] . getSourceColumn ( ) ) == ( numColumn + 1 ) ) { found = true ; typeCode = datasetMetadata . getInfo ( ) . getFields ( ) [ j ] . getDataType ( ) ; <START_BUG> fieldName = Util . cleanStringCamelCase ( datasetMetadata . getInfo ( ) . getFields ( ) [ j ] . getFieldName ( ) ) ; <END_BUG> if ( ( datasetMetadata . getInfo ( ) . getFields ( ) [ j ] . getDateTimeFormat ( ) ) != null ) { try { formatter = new SimpleDateFormat ( datasetMetadata . getInfo ( ) . getFields ( ) [ j ] . getDateTimeFormat ( ) ) ; } catch ( Exception e ) { formatter = Constants . DEFAULT_FIELD_DATE_FORMAT ; } formatter . setTimeZone ( TimeZone . getTimeZone ( "Europe//Rome" ) ) ; } String curValue = fieldValues [ numColumn ] ; if ( ( curValue == null ) || ( ( curValue . length ( ) ) == 0 ) ) { builder . add ( fieldName , null ) ; } else { try { if ( "int" . equals ( typeCode ) ) { builder . add ( fieldName , new Integer ( curValue ) ) ; } else if ( "long" . equals ( typeCode ) ) { builder . add ( fieldName , new Long ( curValue ) ) ; } else if ( "double" . equals ( typeCode ) ) { builder . add ( fieldName , new Double ( curValue ) ) ; } else if ( "float" . equals ( typeCode ) ) { builder . add ( fieldName , new Float ( curValue ) ) ; } else if ( "string" . equals ( typeCode ) ) { builder . add ( fieldName , new String ( curValue ) ) ; } else if ( "boolean" . equals ( typeCode ) ) { builder . add ( fieldName , new Boolean ( Boolean . parseBoolean ( curValue ) ) ) ; } else if ( "dateTime" . equals ( typeCode ) ) { builder . add ( fieldName , formatter . parse ( curValue ) ) ; } else if ( "longitude" . equals ( typeCode ) ) { Double longitude = new Double ( curValue ) ; builder . add ( fieldName , longitude ) ; geoPoint . setLongitude ( longitude ) ; } else if ( "latitude" . equals ( typeCode ) ) { Double latitude = new Double ( curValue ) ; builder . add ( fieldName , latitude ) ; geoPoint . setLatitude ( latitude ) ; } else { builder . add ( fieldName , new String ( curValue ) ) ; } } catch ( Exception e ) { SDPBulkInsertException curRowErr = new SDPBulkInsertException ( SDPBulkInsertException . ERROR_TYPE_INVALIDTYPE , row , lineNumber , numColumn , ( ( ( "Expected<seq2seq4repair_space>value<seq2seq4repair_space>of<seq2seq4repair_space>type<seq2seq4repair_space>" + typeCode ) + "<seq2seq4repair_space>found<seq2seq4repair_space>" ) + curValue ) ) ; errorCurrentRow . add ( curRowErr ) ; } } } numColumn ++ ; }

Fix:
fieldName = datasetMetadata . getInfo ( ) . getFields ( ) [ j ] . getFieldName ( ) ;