Buggy code:
public final class SurveyResponseReadRequest extends UserRequest { private static final Logger LOGGER = Logger . getLogger ( SurveyResponseReadRequest . class ) ; public static final String JSON_KEY_METADATA = "metadata" ; public static final String JSON_KEY_CONTEXT = "context" ; public static final String JSON_KEY_VALUES = "values" ; public static final String JSON_KEY_NUM_SURVEYS = "number_of_surveys" ; public static final String JSON_KEY_NUM_PROMPTS = "number_of_prompts" ; public static final String JSON_KEY_ITEMS = "items" ; public static final String JSON_KEY_COUNT = "count" ; public static final String URN_SPECIAL_ALL = "urn:ohmage:special:all" ; public static final Collection < String > URN_SPECIAL_ALL_LIST ; private static final int MAX_NUMBER_OF_USERS = 10 ; private static final int MAX_NUMBER_OF_SURVEYS = 10 ; private static final int MAX_NUMBER_OF_PROMPTS = 10 ; private final String campaignId ; private final Collection < SurveyResponse . ColumnKey > columns ; private final Collection < String > usernames ; private final OutputFormat outputFormat ; private final Collection < String > surveyIds ; private final Collection < String > promptIds ; private final Date startDate ; private final Date endDate ; private final List < SortParameter > sortOrder ; private final PrivacyState privacyState ; private final Boolean collapse ; private final Boolean prettyPrint ; private final Boolean returnId ; private final Boolean suppressMetadata ; private Campaign campaign ; private List < SurveyResponse > surveyResponseList ; public SurveyResponseReadRequest ( HttpServletRequest httpRequest ) { } @ Override public void service ( ) { SurveyResponseReadRequest . LOGGER . info ( "Servicing<seq2seq4repair_space>a<seq2seq4repair_space>survey<seq2seq4repair_space>response<seq2seq4repair_space>read<seq2seq4repair_space>request." ) ; if ( ! ( authenticate ( NEW_ACCOUNT_DISALLOWED ) ) ) { return ; } try { SurveyResponseReadRequest . LOGGER . info ( "Verifying<seq2seq4repair_space>that<seq2seq4repair_space>requester<seq2seq4repair_space>belongs<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>campaign<seq2seq4repair_space>specified<seq2seq4repair_space>by<seq2seq4repair_space>campaign<seq2seq4repair_space>ID." ) ; UserCampaignServices . instance ( ) . campaignExistsAndUserBelongs ( campaignId , this . getUser ( ) . getUsername ( ) ) ; if ( ! ( usernames . equals ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST ) ) ) { SurveyResponseReadRequest . LOGGER . info ( "Checking<seq2seq4repair_space>the<seq2seq4repair_space>user<seq2seq4repair_space>list<seq2seq4repair_space>to<seq2seq4repair_space>make<seq2seq4repair_space>sure<seq2seq4repair_space>all<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>users<seq2seq4repair_space>belong<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>campaign<seq2seq4repair_space>ID." ) ; UserCampaignServices . instance ( ) . verifyUsersExistInCampaign ( campaignId , usernames ) ; } SurveyResponseReadRequest . LOGGER . info ( "Retrieving<seq2seq4repair_space>campaign<seq2seq4repair_space>configuration." ) ; <START_BUG> campaign = CampaignServices . instance ( ) . getCampaign ( campaignId ) ; <END_BUG> if ( ( ( ( promptIds ) != null ) && ( ! ( promptIds . isEmpty ( ) ) ) ) && ( ! ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( promptIds ) ) ) ) { SurveyResponseReadRequest . LOGGER . info ( "Verifying<seq2seq4repair_space>that<seq2seq4repair_space>the<seq2seq4repair_space>prompt<seq2seq4repair_space>ids<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>query<seq2seq4repair_space>belong<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>campaign." ) ; SurveyResponseReadServices . instance ( ) . verifyPromptIdsBelongToConfiguration ( promptIds , campaign ) ; } if ( ( ( ( surveyIds ) != null ) && ( ! ( surveyIds . isEmpty ( ) ) ) ) && ( ! ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( surveyIds ) ) ) ) { SurveyResponseReadRequest . LOGGER . info ( "Verifying<seq2seq4repair_space>that<seq2seq4repair_space>the<seq2seq4repair_space>survey<seq2seq4repair_space>ids<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>query<seq2seq4repair_space>belong<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>campaign." ) ; SurveyResponseReadServices . instance ( ) . verifySurveyIdsBelongToConfiguration ( surveyIds , campaign ) ; } SurveyResponseReadRequest . LOGGER . info ( "Dispatching<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>data<seq2seq4repair_space>layer." ) ; surveyResponseList = new LinkedList < SurveyResponse > ( ) ; if ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( usernames ) ) { surveyResponseList . addAll ( SurveyResponseServices . instance ( ) . readSurveyResponseInformation ( campaign , null , null , startDate , endDate , privacyState , ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( surveyIds ) ? null : surveyIds ) , ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( promptIds ) ? null : promptIds ) , null ) ) ; } else { for ( String username : usernames ) { surveyResponseList . addAll ( SurveyResponseServices . instance ( ) . readSurveyResponseInformation ( campaign , username , null , startDate , endDate , privacyState , ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( surveyIds ) ? null : surveyIds ) , ( SurveyResponseReadRequest . URN_SPECIAL_ALL_LIST . equals ( promptIds ) ? null : promptIds ) , null ) ) ; } } SurveyResponseReadRequest . LOGGER . info ( ( ( "Found<seq2seq4repair_space>" + ( surveyResponseList . size ( ) ) ) + "<seq2seq4repair_space>results" ) ) ; SurveyResponseReadRequest . LOGGER . info ( "Filtering<seq2seq4repair_space>survey<seq2seq4repair_space>response<seq2seq4repair_space>results<seq2seq4repair_space>according<seq2seq4repair_space>to<seq2seq4repair_space>our<seq2seq4repair_space>privacy<seq2seq4repair_space>rules<seq2seq4repair_space>and<seq2seq4repair_space>the<seq2seq4repair_space>requester's<seq2seq4repair_space>role." ) ; SurveyResponseReadServices . instance ( ) . performPrivacyFilter ( this . getUser ( ) . getUsername ( ) , campaignId , surveyResponseList ) ; SurveyResponseReadRequest . LOGGER . info ( ( ( "Found<seq2seq4repair_space>" + ( surveyResponseList . size ( ) ) ) + "<seq2seq4repair_space>results<seq2seq4repair_space>after<seq2seq4repair_space>filtering." ) ) ; if ( ( sortOrder ) != null ) { SurveyResponseReadRequest . LOGGER . info ( "Sorting<seq2seq4repair_space>the<seq2seq4repair_space>results." ) ; Collections . sort ( surveyResponseList , new Comparator < SurveyResponse > ( ) { @ Override public int compare ( SurveyResponse o1 , SurveyResponse o2 ) { for ( SortParameter sortParameter : sortOrder ) { switch ( sortParameter ) { case SURVEY : if ( ! ( o1 . getSurvey ( ) . equals ( o2 . getSurvey ( ) ) ) ) { return o1 . getSurvey ( ) . getId ( ) . compareTo ( o2 . getSurvey ( ) . getId ( ) ) ; } break ; case TIMESTAMP : if ( ( o1 . getTime ( ) ) != ( o2 . getTime ( ) ) ) { if ( ( ( o1 . getTime ( ) ) - ( o2 . getTime ( ) ) ) < 0 ) { return - 1 ; } else { return 1 ; } } break ; case USER : if ( ! ( o1 . getUsername ( ) . equals ( o2 . getUsername ( ) ) ) ) { return o1 . getUsername ( ) . compareTo ( o2 . getUsername ( ) ) ; } break ; } } return 0 ; } } ) ; } } catch ( ServiceException e ) { e . failRequest ( this ) ; e . logException ( SurveyResponseReadRequest . LOGGER ) ; } } @ Override public void respond ( HttpServletRequest httpRequest , HttpServletResponse httpResponse ) { } private void populatePrompts ( final Map < Integer , SurveyItem > surveyItems , Map < String , JSONObject > prompts ) throws JSONException { }

Fix:
campaign = CampaignServices . instance ( ) . findCampaignConfiguration ( campaignId ) ;