Buggy code:
public class GuessTypesOfColumnCommand extends Command { @ Override public void doPost ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } static final int SAMPLE_SIZE = 10 ; protected List < GuessTypesOfColumnCommand . TypeGroup > guessTypes ( Project project , Column column , String serviceUrl ) throws IOException , JSONException { Map < String , GuessTypesOfColumnCommand . TypeGroup > map = new HashMap < String , GuessTypesOfColumnCommand . TypeGroup > ( ) ; int cellIndex = column . getCellIndex ( ) ; List < String > samples = new ArrayList < String > ( GuessTypesOfColumnCommand . SAMPLE_SIZE ) ; Set < String > sampleSet = new HashSet < String > ( ) ; for ( Row row : project . rows ) { Object value = row . getCellValue ( cellIndex ) ; if ( ExpressionUtils . isNonBlankData ( value ) ) { String s = value . toString ( ) . trim ( ) ; if ( ! ( sampleSet . contains ( s ) ) ) { samples . add ( s ) ; sampleSet . add ( s ) ; if ( ( samples . size ( ) ) >= ( GuessTypesOfColumnCommand . SAMPLE_SIZE ) ) { break ; } } } } StringWriter stringWriter = new StringWriter ( ) ; try { JSONWriter jsonWriter = new JSONWriter ( stringWriter ) ; jsonWriter . object ( ) ; for ( int i = 0 ; i < ( samples . size ( ) ) ; i ++ ) { jsonWriter . key ( ( "q" + i ) ) ; jsonWriter . object ( ) ; jsonWriter . key ( "query" ) ; jsonWriter . value ( samples . get ( i ) ) ; jsonWriter . key ( "limit" ) ; jsonWriter . value ( 3 ) ; jsonWriter . endObject ( ) ; } jsonWriter . endObject ( ) ; } catch ( JSONException e ) { logger . error ( "Error<seq2seq4repair_space>constructing<seq2seq4repair_space>query" , e ) ; } String queriesString = stringWriter . toString ( ) ; try { URL url = new URL ( serviceUrl ) ; HttpURLConnection connection = ( ( HttpURLConnection ) ( url . openConnection ( ) ) ) ; { <START_BUG> connection . setRequestProperty ( "Content-Type" , "application//x-www-form-urlencoded" ) ; <END_BUG> connection . setConnectTimeout ( 30000 ) ; connection . setDoOutput ( true ) ; DataOutputStream dos = new DataOutputStream ( connection . getOutputStream ( ) ) ; try { String body = "queries=" + ( ParsingUtilities . encode ( queriesString ) ) ; dos . writeBytes ( body ) ; } finally { dos . flush ( ) ; dos . close ( ) ; } connection . connect ( ) ; } if ( ( connection . getResponseCode ( ) ) >= 400 ) { InputStream is = connection . getErrorStream ( ) ; throw new IOException ( ( ( ( ( "Failed<seq2seq4repair_space>-<seq2seq4repair_space>code:" + ( Integer . toString ( connection . getResponseCode ( ) ) ) ) + "<seq2seq4repair_space>message:<seq2seq4repair_space>" ) + is ) == null ? "" : ParsingUtilities . inputStreamToString ( is ) ) ) ; } else { InputStream is = connection . getInputStream ( ) ; try { String s = ParsingUtilities . inputStreamToString ( is ) ; JSONObject o = ParsingUtilities . evaluateJsonStringToObject ( s ) ; for ( int i = 0 ; i < ( samples . size ( ) ) ; i ++ ) { String key = "q" + i ; if ( ! ( o . has ( key ) ) ) { continue ; } JSONObject o2 = o . getJSONObject ( key ) ; if ( ! ( o2 . has ( "result" ) ) ) { continue ; } JSONArray results = o2 . getJSONArray ( "result" ) ; int count = results . length ( ) ; for ( int j = 0 ; j < count ; j ++ ) { JSONObject result = results . getJSONObject ( j ) ; double score = 1.0 // ( 1 + j ) ; JSONArray types = result . getJSONArray ( "type" ) ; int typeCount = types . length ( ) ; for ( int t = 0 ; t < typeCount ; t ++ ) { Object type = types . get ( t ) ; String typeID ; String typeName ; if ( type instanceof String ) { typeID = typeName = ( ( String ) ( type ) ) ; } else { typeID = ( ( JSONObject ) ( type ) ) . getString ( "id" ) ; typeName = ( ( JSONObject ) ( type ) ) . getString ( "name" ) ; } double score2 = ( score * ( typeCount - t ) ) // typeCount ; if ( map . containsKey ( typeID ) ) { GuessTypesOfColumnCommand . TypeGroup tg = map . get ( typeID ) ; tg . score += score2 ; ( tg . count ) ++ ; } else { map . put ( typeID , new GuessTypesOfColumnCommand . TypeGroup ( typeID , typeName , score2 ) ) ; } } } } } finally { is . close ( ) ; } } } catch ( IOException e ) { logger . error ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>guess<seq2seq4repair_space>cell<seq2seq4repair_space>types<seq2seq4repair_space>for<seq2seq4repair_space>load\n" + queriesString ) , e ) ; throw e ; } List < GuessTypesOfColumnCommand . TypeGroup > types = new ArrayList < GuessTypesOfColumnCommand . TypeGroup > ( map . values ( ) ) ; Collections . sort ( types , new Comparator < GuessTypesOfColumnCommand . TypeGroup > ( ) { @ Override public int compare ( GuessTypesOfColumnCommand . TypeGroup o1 , GuessTypesOfColumnCommand . TypeGroup o2 ) { int c = ( Math . min ( GuessTypesOfColumnCommand . SAMPLE_SIZE , o2 . count ) ) - ( Math . min ( GuessTypesOfColumnCommand . SAMPLE_SIZE , o1 . count ) ) ; if ( c != 0 ) { return c ; }

Fix:
connection . setRequestProperty ( "Content-Type" , "application//x-www-form-urlencoded;<seq2seq4repair_space>charset=UTF-8" ) ;