Buggy code:
public class SurveyManager { private static Logger log = Logger . getLogger ( SurveyManager . class . getName ( ) ) ; public ArrayList < Survey > getSurveys ( Connection sd , PreparedStatement pstmt , String user , boolean getDeleted , boolean getBlocked , int projectId ) throws SQLException { } public boolean surveyExists ( Connection sd , String displayName , int projectId ) { } public Survey getById ( Connection sd , Connection cResults , String user , int sId , boolean full , String basePath , String instanceId , boolean getResults ) throws Exception , SQLException { } public ArrayList < Survey > getByOrganisationAndExternalCSV ( Connection sd , String user , String csvFileName ) { } private void populateSurvey ( Connection sd , Survey s , String basePath , String user ) throws Exception { } public Survey getSurveyId ( Connection sd , String key ) { } public ChangeResponse applyChangeSetArray ( Connection connectionSD , int sId , String ident , ArrayList < ChangeSet > changes ) throws Exception { ChangeResponse resp = new ChangeResponse ( ) ; resp . changeSet = changes ; int userId = - 1 ; ResultSet rs = null ; PreparedStatement pstmtChangeLog = null ; PreparedStatement pstmt = null ; try { String sqlChangeLog = "insert<seq2seq4repair_space>into<seq2seq4repair_space>survey_change<seq2seq4repair_space>" + ( "(s_id,<seq2seq4repair_space>version,<seq2seq4repair_space>changes,<seq2seq4repair_space>user_id,<seq2seq4repair_space>apply_results,<seq2seq4repair_space>updated_time)<seq2seq4repair_space>" + "values(?,<seq2seq4repair_space>?,<seq2seq4repair_space>?,<seq2seq4repair_space>?,<seq2seq4repair_space>?,<seq2seq4repair_space>?)" ) ; pstmtChangeLog = connectionSD . prepareStatement ( sqlChangeLog ) ; String sqlGetUser = "select<seq2seq4repair_space>id<seq2seq4repair_space>from<seq2seq4repair_space>users<seq2seq4repair_space>where<seq2seq4repair_space>ident<seq2seq4repair_space>=<seq2seq4repair_space>?" ; pstmt = connectionSD . prepareStatement ( sqlGetUser ) ; pstmt . setString ( 1 , ident ) ; rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { userId = rs . getInt ( 1 ) ; } pstmt . close ( ) ; connectionSD . setAutoCommit ( false ) ; String sqlUpdateVersion = "update<seq2seq4repair_space>survey<seq2seq4repair_space>set<seq2seq4repair_space>version<seq2seq4repair_space>=<seq2seq4repair_space>version<seq2seq4repair_space>+<seq2seq4repair_space>1<seq2seq4repair_space>where<seq2seq4repair_space>s_id<seq2seq4repair_space>=<seq2seq4repair_space>?" ; String sqlGetVersion = "select<seq2seq4repair_space>version<seq2seq4repair_space>from<seq2seq4repair_space>survey<seq2seq4repair_space>where<seq2seq4repair_space>s_id<seq2seq4repair_space>=<seq2seq4repair_space>?" ; pstmt = connectionSD . prepareStatement ( sqlUpdateVersion ) ; pstmt . setInt ( 1 , sId ) ; pstmt . execute ( ) ; pstmt . close ( ) ; pstmt = connectionSD . prepareStatement ( sqlGetVersion ) ; pstmt . setInt ( 1 , sId ) ; rs = pstmt . executeQuery ( ) ; rs . next ( ) ; resp . version = rs . getInt ( 1 ) ; pstmt . close ( ) ; for ( ChangeSet cs : changes ) { Savepoint sp = connectionSD . setSavepoint ( ) ; try { SurveyManager . log . info ( ( "SurveyManager,<seq2seq4repair_space>applyChanges.<seq2seq4repair_space>Change<seq2seq4repair_space>set<seq2seq4repair_space>type:<seq2seq4repair_space>" + ( cs . changeType ) ) ) ; <START_BUG> if ( ( cs . changeType . equals ( "label" ) ) || ( cs . changeType . equals ( "media" ) ) ) { <END_BUG> applyLabel ( connectionSD , pstmtChangeLog , cs . items , sId , userId , resp . version ) ; } else if ( cs . changeType . equals ( "option_update" ) ) { applyOptionUpdates ( connectionSD , pstmtChangeLog , cs . items , sId , userId , resp . version , cs . changeType ) ; } else if ( cs . changeType . equals ( "property" ) ) { applyProperty ( connectionSD , pstmtChangeLog , cs . items , sId , userId , resp . version , cs . changeType ) ; } else if ( cs . changeType . equals ( "question" ) ) { applyQuestion ( connectionSD , pstmtChangeLog , cs . items , sId , userId , resp . version , cs . changeType , cs . action ) ; } else { throw new Exception ( ( "Error:<seq2seq4repair_space>unknown<seq2seq4repair_space>changeset<seq2seq4repair_space>type:<seq2seq4repair_space>" + ( cs . changeType ) ) ) ; } cs . updateFailed = false ; ( resp . success ) ++ ; } catch ( Exception e ) { connectionSD . rollback ( sp ) ; String msg = e . getMessage ( ) ; SurveyManager . log . info ( ( "Error:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ; cs . updateFailed = true ; cs . errorMsg = e . getMessage ( ) ; ( resp . failed ) ++ ; } } if ( ( resp . success ) > 0 ) { connectionSD . commit ( ) ; SurveyManager . log . info ( ( ( ( ( ( ( "Survey<seq2seq4repair_space>update<seq2seq4repair_space>to<seq2seq4repair_space>version:<seq2seq4repair_space>" + ( resp . version ) ) + ".<seq2seq4repair_space>" ) + ( resp . success ) ) + "<seq2seq4repair_space>successful<seq2seq4repair_space>changes<seq2seq4repair_space>and<seq2seq4repair_space>" ) + ( resp . failed ) ) + "<seq2seq4repair_space>failed<seq2seq4repair_space>changes" ) ) ; } else { connectionSD . rollback ( ) ; SurveyManager . log . info ( ( ( ( ( "Survey<seq2seq4repair_space>version<seq2seq4repair_space>not<seq2seq4repair_space>updated:<seq2seq4repair_space>" + ( resp . success ) ) + "<seq2seq4repair_space>successful<seq2seq4repair_space>changes<seq2seq4repair_space>and<seq2seq4repair_space>" ) + ( resp . failed ) ) + "<seq2seq4repair_space>failed<seq2seq4repair_space>changes" ) ) ; } } catch ( Exception e ) { SurveyManager . log . log ( Level . SEVERE , "Error" , e ) ; throw e ; } finally { try { if ( pstmtChangeLog != null ) { pstmtChangeLog . close ( ) ; } } catch ( SQLException e ) { } try { if ( pstmt != null ) { pstmt . close ( ) ; } } catch ( SQLException e ) { } } return resp ; } public static Timestamp getTimeStamp ( ) { } public void applyLabel ( Connection connectionSD , PreparedStatement pstmtChangeLog , ArrayList < ChangeItem > changeItemList , int sId , int userId , int version ) throws Exception { } public void updateLabel ( ChangeItem ci , String language , PreparedStatement pstmtLangOldVal , int sId ) throws Exception , SQLException { } public void addLabel ( ChangeItem ci , String language , PreparedStatement pstmtLangNew , int sId , PreparedStatement pstmtDeleteLabel ) throws Exception , SQLException { } public void applyOptionUpdates ( Connection connectionSD , PreparedStatement pstmtChangeLog , ArrayList < ChangeItem > changeItemList , int sId , int userId , int version , String changeType ) throws Exception { }

Fix:
if ( cs . changeType . equals ( "label" ) ) {