Program: 34032
Project: 34032
Buggy source:
private void buildVendorSpinner(ArrayList<Vendor> vendorList,String selectedVendor){
  if (vendorMap == null) {
    vendorMap=new TreeMap<>();
  }
  if (vendorMapIdAsKey == null) {
    vendorMapIdAsKey=new TreeMap<>();
  }
  if (vendorList != null) {
    for (    Vendor vendor : vendorList) {
      try {
        vendorMap.put(vendor.getName(),vendor.getId());
        vendorMapIdAsKey.put(vendor.getId(),vendor.getName());
      }
 catch (      EvercamException e) {
        Log.e(TAG,e.toString());
      }
    }
  }
  Set<String> set=vendorMap.keySet();
  String[] vendorArray=Commons.joinStringArray(new String[]{getResources().getString(R.string.select_vendor)},set.toArray(new String[0]));
  ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,vendorArray);
  spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner);
  int selectedPosition=0;
  if (discoveredCamera != null) {
    if (discoveredCamera.hasVendor()) {
      String vendorId=discoveredCamera.getVendor();
      String vendorName=vendorMapIdAsKey.get(vendorId);
      selectedPosition=spinnerArrayAdapter.getPosition(vendorName);
    }
  }
  if (selectedVendor != null) {
    selectedPosition=spinnerArrayAdapter.getPosition(selectedVendor);
  }
  vendorSpinner.setAdapter(spinnerArrayAdapter);
  if (selectedPosition != 0) {
    vendorSpinner.setSelection(selectedPosition);
  }
 else   if (vendorSavedSelectedPosition != 0) {
    vendorSpinner.setSelection(vendorSavedSelectedPosition);
    vendorSavedSelectedPosition=0;
  }
}

Fixed version (ground truth):
private void buildVendorSpinner(ArrayList<Vendor> vendorList,String selectedVendor){
  if (vendorMap == null) {
    vendorMap=new TreeMap<>();
  }
  if (vendorMapIdAsKey == null) {
    vendorMapIdAsKey=new TreeMap<>();
  }
  if (vendorList != null) {
    for (    Vendor vendor : vendorList) {
      try {
        vendorMap.put(vendor.getName(),vendor.getId());
        vendorMapIdAsKey.put(vendor.getId(),vendor.getName());
      }
 catch (      EvercamException e) {
        Log.e(TAG,e.toString());
      }
    }
  }
  Set<String> set=vendorMap.keySet();
  String[] vendorArray=Commons.joinStringArray(new String[]{getResources().getString(R.string.select_vendor)},set.toArray(new String[0]));
  ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,vendorArray);
  spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner);
  int selectedPosition=0;
  if (discoveredCamera != null) {
    if (discoveredCamera.hasVendor()) {
      String vendorId=discoveredCamera.getVendor();
      String vendorName=vendorMapIdAsKey.get(vendorId);
      selectedPosition=spinnerArrayAdapter.getPosition(vendorName);
    }
  }
  if (selectedVendor != null) {
    selectedPosition=spinnerArrayAdapter.getPosition(selectedVendor);
  }
  vendorSpinner.setAdapter(spinnerArrayAdapter);
  if (selectedPosition != 0) {
    vendorSpinner.setSelection(selectedPosition);
  }
 else   if (vendorSavedSelectedPosition != 0 && vendorSpinner.getCount() > 1 && vendorSavedSelectedPosition < vendorSpinner.getCount()) {
    vendorSpinner.setSelection(vendorSavedSelectedPosition);
    vendorSavedSelectedPosition=0;
  }
}