Buggy code:
} @ Override public void readObject ( JsonNode survey ) { responseIDs . add ( survey . get ( "survey_key" ) . asText ( ) ) ; } @ Override public void afterRead ( ) { if ( ( ( responseIDs ) == null ) || ( ( responseIDs . size ( ) ) <= 0 ) ) return ; String [ ] args = responseIDs . toArray ( new String [ responseIDs . size ( ) ] ) ; StringBuilder total = new StringBuilder ( ) ; for ( int i = 0 ; i < ( args . length ) ; ++ i ) { total . append ( "?" ) ; if ( i < ( ( args . length ) - 1 ) ) total . append ( ",<seq2seq4repair_space>" ) ; } int delCount = cr . delete ( Responses . CONTENT_URI , ( ( ( ( ( ( ( ( ( ( ( ( ( Responses . RESPONSE_STATUS ) + "=" ) + ( Response . STATUS_DOWNLOADED ) ) + "<seq2seq4repair_space>AND<seq2seq4repair_space>" ) + ( Responses . CAMPAIGN_URN ) ) + "='" ) + ( c . mUrn ) ) + "'" ) + "<seq2seq4repair_space>AND<seq2seq4repair_space>" ) + ( Responses . RESPONSE_UUID ) ) + "<seq2seq4repair_space>not<seq2seq4repair_space>in<seq2seq4repair_space>(" ) + total ) + ")" ) , args ) ; Log . v ( ResponseSyncService . TAG , ( ( ( "Finished<seq2seq4repair_space>UUID<seq2seq4repair_space>read,<seq2seq4repair_space>deleted<seq2seq4repair_space>" + delCount ) + "<seq2seq4repair_space>stale<seq2seq4repair_space>record(s)<seq2seq4repair_space>out<seq2seq4repair_space>of<seq2seq4repair_space>" ) + ( args . length ) ) ) ; } } ) ; class ResponseImage { public ResponseImage ( String c , String id ) { } String campaign ; String uuid ; } final LinkedList < ResponseImage > responsePhotos = new LinkedList < ResponseImage > ( ) ; api . surveyResponseRead ( DEFAULT_SERVER_URL , username , hashedPassword , "android" , c . mUrn , username , null , null , "json-rows" , true , cutoffDate , nearFutureDate , new StreamingResponseListener ( ) { int curRecord ; @ Override public void beforeRead ( ) { Log . v ( ResponseSyncService . TAG , "Beginning<seq2seq4repair_space>record<seq2seq4repair_space>read..." ) ; curRecord = 0 ; } @ Override public void readObject ( JsonNode survey ) { Log . v ( ResponseSyncService . TAG , ( ( ( ( "Processing<seq2seq4repair_space>record<seq2seq4repair_space>" + ( ( ( curRecord ) ++ ) + 1 ) ) + "<seq2seq4repair_space>in<seq2seq4repair_space>" ) + ( c . mUrn ) ) + "..." ) ) ; ArrayList < String > photoUUIDs = new ArrayList < String > ( ) ; try { Response candidate = new Response ( ) ; candidate . uuid = survey . get ( "survey_key" ) . asText ( ) ; candidate . surveyId = survey . get ( "survey_id" ) . asText ( ) ; candidate . campaignUrn = c . mUrn ; candidate . username = survey . get ( "user" ) . asText ( ) ; candidate . date = survey . get ( "timestamp" ) . asText ( ) ; candidate . timezone = survey . get ( "timezone" ) . asText ( ) ; candidate . time = survey . get ( "time" ) . asLong ( ) ; candidate . locationStatus = survey . get ( "location_status" ) . asText ( ) ; candidate . locationLatitude = survey . path ( "latitude" ) . asDouble ( ) ; candidate . locationLongitude = survey . path ( "longitude" ) . asDouble ( ) ; candidate . locationProvider = survey . path ( "location_provider" ) . asText ( ) ; candidate . locationAccuracy = ( ( float ) ( survey . path ( "location_accuracy" ) . asDouble ( ) ) ) ; candidate . locationTime = survey . path ( "location_timestamp" ) . asLong ( ) ; candidate . surveyLaunchContext = survey . get ( "launch_context_long" ) . asText ( ) ; JsonNode inputResponses = survey . get ( "responses" ) ; JSONArray responseJson = new JSONArray ( ) ; Iterator < String > keys = inputResponses . getFieldNames ( ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; JsonNode curItem = inputResponses . get ( key ) ; if ( curItem . has ( "prompt_response" ) ) { JSONObject newItem = new JSONObject ( ) ; try { <START_BUG> String value = curItem . get ( "prompt_response" ) . asText ( ) ; <END_BUG> String type = curItem . get ( "prompt_type" ) . asText ( ) ; newItem . put ( "prompt_id" , key ) ; if ( curItem . has ( "prompt_choice_glossary" ) ) { if ( ( type . equals ( "single_choice_custom" ) ) || ( type . equals ( "multi_choice_custom" ) ) ) { JSONArray customChoiceArray = new JSONArray ( ) ; JsonNode glossary = curItem . get ( "prompt_choice_glossary" ) ; Iterator < String > glossaryKeys = glossary . getFieldNames ( ) ; while ( glossaryKeys . hasNext ( ) ) { String glossaryKey = glossaryKeys . next ( ) ; JsonNode curGlossaryItem = glossary . get ( glossaryKey ) ; JSONObject newChoiceItem = new JSONObject ( ) ; newChoiceItem . put ( "choice_value" , curGlossaryItem . get ( "label" ) . asText ( ) ) ; newChoiceItem . put ( "choice_id" , glossaryKey ) ; customChoiceArray . put ( newChoiceItem ) ; } newItem . put ( "custom_choices" , customChoiceArray ) ; } } if ( ( ( curItem . get ( "prompt_type" ) . asText ( ) . equalsIgnoreCase ( "photo" ) ) && ( ! ( value . equalsIgnoreCase ( NOT_DISPLAYED_VALUE ) ) ) ) && ( ! ( value . equalsIgnoreCase ( SKIPPED_VALUE ) ) ) ) { photoUUIDs . add ( value ) ; } newItem . put ( "value" , value ) ; } catch ( JSONException e ) { Log . e ( ResponseSyncService . TAG , "JSONException<seq2seq4repair_space>when<seq2seq4repair_space>trying<seq2seq4repair_space>to<seq2seq4repair_space>generate<seq2seq4repair_space>response<seq2seq4repair_space>json" , e ) ; throw new JSONException ( "error<seq2seq4repair_space>generating<seq2seq4repair_space>response<seq2seq4repair_space>json" ) ; } responseJson . put ( newItem ) ; }

Fix:
String value = ( curItem . get ( "prompt_response" ) . isValueNode ( ) ) ? curItem . get ( "prompt_response" ) . asText ( ) : curItem . get ( "prompt_response" ) . toString ( ) ;