Program: 161536
Project: 161536
Buggy source:
@Override public void onClick(View view){
  if (!checkSurveyData()) {
    return;
  }
  final ArrayList<String> selectedFacIds=new ArrayList<String>();
  if (!selectedFaculties.isEmpty()) {
    for (int j=0; j < selectedFaculties.size(); j++) {
      for (int x=0; x < fetchedFaculties.size(); x++) {
        if (selectedFaculties.get(j).equals(fetchedFaculties.get(x))) {
          Cursor cursor=surveyManager.getFacultyID(selectedFaculties.get(j));
          if (cursor.moveToFirst()) {
            selectedFacIds.add(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
          }
        }
      }
    }
  }
 else {
    Cursor c=surveyManager.getAllFaculties();
    if (c.moveToFirst()) {
      do {
        selectedFacIds.add(c.getString(c.getColumnIndex("String_Node_Str")));
      }
 while (c.moveToNext());
    }
  }
  if (NetUtils.isConnected(getApplication())) {
    for (int i=0; i < aSpinner1.getSelectedItemPosition() + 1; i++) {
      Question ques=new Question(questions.get(i),selectedFacIds);
      try {
        TUMCabeClient.getInstance(getApplicationContext()).createQuestion(ques,new Callback<Question>(){
          @Override public void success(          Question question,          Response response){
            Utils.log("String_Node_Str" + response.getBody().toString());
            numberOfQuestion++;
            Toast.makeText(getApplicationContext(),getResources().getString(R.string.survey_submitted),Toast.LENGTH_SHORT).show();
          }
          @Override public void failure(          RetrofitError error){
            Utils.log("String_Node_Str" + error.toString());
          }
        }
);
      }
 catch (      Exception e) {
        Utils.log(e.toString());
      }
    }
    clearData();
    new AsyncTask<Void,Void,Void>(){
      @Override protected Void doInBackground(      Void... voids){
        surveyManager.downLoadOwnQuestions();
        return null;
      }
      @Override protected void onPostExecute(      Void v){
        restartActivity();
      }
    }
.execute();
  }
 else   restartActivity();
}

Fixed version (ground truth):
@Override public void onClick(View view){
  if (!checkSurveyData()) {
    return;
  }
  final ArrayList<String> selectedFacIds=new ArrayList<String>();
  if (!selectedFaculties.isEmpty()) {
    for (int j=0; j < selectedFaculties.size(); j++) {
      for (int x=0; x < fetchedFaculties.size(); x++) {
        if (selectedFaculties.get(j).equals(fetchedFaculties.get(x))) {
          Cursor cursor=surveyManager.getFacultyID(selectedFaculties.get(j));
          if (cursor.moveToFirst()) {
            selectedFacIds.add(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
          }
        }
      }
    }
  }
 else {
    Cursor c=surveyManager.getAllFaculties();
    if (c.moveToFirst()) {
      do {
        selectedFacIds.add(c.getString(c.getColumnIndex("String_Node_Str")));
      }
 while (c.moveToNext());
    }
  }
  if (NetUtils.isConnected(getApplication())) {
    new AsyncTask<Void,Void,Void>(){
      @Override protected void onPreExecute(){
        for (int i=0; i < aSpinner1.getSelectedItemPosition() + 1; i++) {
          Question ques=new Question(questions.get(i),selectedFacIds);
          try {
            TUMCabeClient.getInstance(getApplicationContext()).createQuestion(ques,new Callback<Question>(){
              @Override public void success(              Question question,              Response response){
                Utils.log("String_Node_Str" + response.getBody().toString());
                numberOfQuestion++;
                Toast.makeText(getApplicationContext(),getResources().getString(R.string.survey_submitted),Toast.LENGTH_SHORT).show();
              }
              @Override public void failure(              RetrofitError error){
                Utils.log("String_Node_Str" + error.toString());
              }
            }
);
          }
 catch (          Exception e) {
            Utils.log(e.toString());
          }
        }
      }
      @Override protected Void doInBackground(      Void... voids){
        try {
          Thread.sleep(1000);
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
        surveyManager.downLoadOwnQuestions();
        return null;
      }
      @Override protected void onPostExecute(      Void v){
        finish();
        clearData();
        restartActivity();
      }
    }
.execute();
  }
 else {
    restartActivity();
  }
}