Program: 29739
Project: 29739
Buggy source:
public void writeTag(Tag tag,String openhabUri){
  Log.d(TAG,"String_Node_Str");
  TextView writeTagMessage=(TextView)findViewById(R.id.write_tag_message);
  if (openhabUri == null) {
    writeTagMessage.setText(R.string.info_write_failed);
    return;
  }
  if (openhabUri.length() == 0) {
    writeTagMessage.setText(R.string.info_write_failed);
    return;
  }
  NdefRecord[] ndefRecords;
  ndefRecords=new NdefRecord[1];
  ndefRecords[0]=NdefRecord.createUri(openhabUri);
  NdefMessage message=new NdefMessage(ndefRecords);
  NdefFormatable ndefFormatable=NdefFormatable.get(tag);
  if (ndefFormatable != null) {
    Log.d(TAG,"String_Node_Str");
    try {
      ndefFormatable.connect();
      ndefFormatable.format(message);
      ndefFormatable.close();
      writeTagMessage.setText(R.string.info_write_tag_finished);
      autoCloseActivity();
    }
 catch (    IOException e) {
      if (e.getMessage() != null)       Log.e(TAG,e.getMessage());
      writeTagMessage.setText(R.string.info_write_failed);
    }
catch (    FormatException e) {
      Log.e(TAG,e.getMessage());
      writeTagMessage.setText(R.string.info_write_failed);
    }
  }
 else {
    Log.d(TAG,"String_Node_Str");
    Ndef ndef=Ndef.get(tag);
    if (ndef != null) {
      try {
        Log.d(TAG,"String_Node_Str");
        ndef.connect();
        Log.d(TAG,"String_Node_Str");
        if (ndef.isWritable()) {
          ndef.writeNdefMessage(message);
        }
        Log.d(TAG,"String_Node_Str");
        ndef.close();
        writeTagMessage.setText(R.string.info_write_tag_finished);
        autoCloseActivity();
      }
 catch (      IOException e) {
        if (e != null)         Log.e(TAG,e.getMessage());
      }
catch (      FormatException e) {
        Log.e(TAG,e.getMessage());
      }
    }
 else {
      Log.e(TAG,"String_Node_Str");
      writeTagMessage.setText(R.string.info_write_failed);
    }
  }
}

Fixed version (ground truth):
public void writeTag(Tag tag,String openhabUri){
  Log.d(TAG,"String_Node_Str");
  TextView writeTagMessage=(TextView)findViewById(R.id.write_tag_message);
  if (openhabUri == null) {
    writeTagMessage.setText(R.string.info_write_failed);
    return;
  }
  if (openhabUri.length() == 0) {
    writeTagMessage.setText(R.string.info_write_failed);
    return;
  }
  NdefRecord[] ndefRecords;
  ndefRecords=new NdefRecord[1];
  ndefRecords[0]=NdefRecord.createUri(openhabUri);
  NdefMessage message=new NdefMessage(ndefRecords);
  NdefFormatable ndefFormatable=NdefFormatable.get(tag);
  if (ndefFormatable != null) {
    Log.d(TAG,"String_Node_Str");
    try {
      ndefFormatable.connect();
      ndefFormatable.format(message);
      ndefFormatable.close();
      writeTagMessage.setText(R.string.info_write_tag_finished);
      autoCloseActivity();
    }
 catch (    IOException e) {
      if (e.getMessage() != null)       Log.e(TAG,e.getMessage());
      writeTagMessage.setText(R.string.info_write_failed);
    }
catch (    FormatException e) {
      Log.e(TAG,e.getMessage());
      writeTagMessage.setText(R.string.info_write_failed);
    }
  }
 else {
    Log.d(TAG,"String_Node_Str");
    Ndef ndef=Ndef.get(tag);
    if (ndef != null) {
      try {
        Log.d(TAG,"String_Node_Str");
        ndef.connect();
        Log.d(TAG,"String_Node_Str");
        if (ndef.isWritable()) {
          ndef.writeNdefMessage(message);
        }
        Log.d(TAG,"String_Node_Str");
        ndef.close();
        writeTagMessage.setText(R.string.info_write_tag_finished);
        autoCloseActivity();
      }
 catch (      IOException e) {
        if (e != null)         Log.e(TAG,e.getClass().getCanonicalName());
        writeTagMessage.setText(R.string.info_write_failed);
      }
catch (      FormatException e) {
        Log.e(TAG,e.getMessage());
        writeTagMessage.setText(R.string.info_write_failed);
      }
    }
 else {
      Log.e(TAG,"String_Node_Str");
      writeTagMessage.setText(R.string.info_write_failed);
    }
  }
}