Program: 172517
Project: 172517
Buggy source:
public Message doc(String doc){
  if (Pattern.matches("String_Node_Str",doc)) {
    this.attachments.add(doc.substring(doc.lastIndexOf("String_Node_Str")));
    return this;
  }
  String type=null;
  File docFile=new File(doc);
  if (docFile.exists()) {
    type="String_Node_Str";
  }
  URL docUrl=null;
  if (type == null) {
    try {
      docUrl=new URL(doc);
      type="String_Node_Str";
    }
 catch (    MalformedURLException ignored) {
      LOG.error("String_Node_Str",doc);
      return this;
    }
  }
  byte[] docBytes;
switch (type) {
case "String_Node_Str":
{
      try {
        docBytes=Files.readAllBytes(Paths.get(docFile.toURI()));
      }
 catch (      IOException ignored) {
        LOG.error("String_Node_Str",docFile.getAbsolutePath());
        return this;
      }
      break;
    }
case "String_Node_Str":
{
    try {
      docBytes=Utils.toByteArray(docUrl);
    }
 catch (    IOException ignored) {
      LOG.error("String_Node_Str",ignored.toString(),doc);
      return this;
    }
    break;
  }
default :
{
  LOG.error("String_Node_Str",doc);
  return this;
}
}
if (docBytes != null) {
String getUploadServerQuery="String_Node_Str" + accessToken + "String_Node_Str"+ this.peerId+ "String_Node_Str";
JSONObject getUploadServerResponse=Connection.getRequestResponse(getUploadServerQuery);
String uploadUrl=getUploadServerResponse.has("String_Node_Str") ? getUploadServerResponse.getJSONObject("String_Node_Str").has("String_Node_Str") ? getUploadServerResponse.getJSONObject("String_Node_Str").getString("String_Node_Str") : null : null;
if (uploadUrl == null) {
LOG.error("String_Node_Str",getUploadServerResponse);
return this;
}
String uploadingOfDocResponseString=Connection.getFileUploadAnswerOfVK(uploadUrl,"String_Node_Str",MediaType.parse("String_Node_Str"),docBytes);
JSONObject uploadingOfDocResponse;
try {
uploadingOfDocResponse=new JSONObject(uploadingOfDocResponseString);
}
 catch (JSONException ignored) {
LOG.error("String_Node_Str",uploadingOfDocResponseString,ignored.toString());
return this;
}
String file;
if (uploadingOfDocResponse.has("String_Node_Str")) {
file=uploadingOfDocResponse.getString("String_Node_Str");
}
 else {
LOG.error("String_Node_Str",uploadingOfDocResponseString);
return this;
}
String saveMessagesDocQuery="String_Node_Str" + accessToken + "String_Node_Str"+ file;
JSONObject saveMessagesDocResponse=Connection.getRequestResponse(saveMessagesDocQuery);
String docAsAttach=saveMessagesDocResponse.has("String_Node_Str") ? "String_Node_Str" + saveMessagesDocResponse.getJSONArray("String_Node_Str").getJSONObject(0).getInt("String_Node_Str") + "String_Node_Str"+ saveMessagesDocResponse.getJSONArray("String_Node_Str").getJSONObject(0).getInt("String_Node_Str") : "String_Node_Str";
this.attachments.add(docAsAttach);
}
return this;
}

Fixed version (ground truth):
public Message doc(String doc,String... typeOfDoc){
  if (Pattern.matches("String_Node_Str",doc)) {
    this.attachments.add(doc.substring(doc.lastIndexOf("String_Node_Str")));
    return this;
  }
  String type=null;
  File docFile=new File(doc);
  if (docFile.exists()) {
    type="String_Node_Str";
  }
  URL docUrl=null;
  if (type == null) {
    try {
      docUrl=new URL(doc);
      type="String_Node_Str";
    }
 catch (    MalformedURLException ignored) {
      LOG.error("String_Node_Str",doc);
      return this;
    }
  }
  byte[] docBytes;
switch (type) {
case "String_Node_Str":
{
      try {
        docBytes=Files.readAllBytes(Paths.get(docFile.toURI()));
      }
 catch (      IOException ignored) {
        LOG.error("String_Node_Str",docFile.getAbsolutePath());
        return this;
      }
      break;
    }
case "String_Node_Str":
{
    try {
      docBytes=Utils.toByteArray(docUrl);
    }
 catch (    IOException ignored) {
      LOG.error("String_Node_Str",ignored.toString(),doc);
      return this;
    }
    break;
  }
default :
{
  LOG.error("String_Node_Str",doc);
  return this;
}
}
if (docBytes != null) {
String getUploadServerQuery="String_Node_Str" + accessToken + "String_Node_Str"+ this.peerId+ "String_Node_Str"+ (typeOfDoc.length > 0 ? "String_Node_Str" + typeOfDoc[0] : "String_Node_Str");
LOG.error("String_Node_Str",getUploadServerQuery);
JSONObject getUploadServerResponse=Connection.getRequestResponse(getUploadServerQuery);
String uploadUrl=getUploadServerResponse.has("String_Node_Str") ? getUploadServerResponse.getJSONObject("String_Node_Str").has("String_Node_Str") ? getUploadServerResponse.getJSONObject("String_Node_Str").getString("String_Node_Str") : null : null;
if (uploadUrl == null) {
LOG.error("String_Node_Str",getUploadServerResponse);
return this;
}
String uploadingOfDocResponseString=Connection.getFileUploadAnswerOfVK(uploadUrl,"String_Node_Str",MediaType.parse("String_Node_Str"),docBytes);
JSONObject uploadingOfDocResponse;
try {
uploadingOfDocResponse=new JSONObject(uploadingOfDocResponseString);
}
 catch (JSONException ignored) {
LOG.error("String_Node_Str",uploadingOfDocResponseString,ignored.toString());
return this;
}
String file;
if (uploadingOfDocResponse.has("String_Node_Str")) {
file=uploadingOfDocResponse.getString("String_Node_Str");
}
 else {
LOG.error("String_Node_Str",uploadingOfDocResponseString);
return this;
}
String saveMessagesDocQuery="String_Node_Str" + accessToken + "String_Node_Str"+ file;
JSONObject saveMessagesDocResponse=Connection.getRequestResponse(saveMessagesDocQuery);
String docAsAttach=saveMessagesDocResponse.has("String_Node_Str") ? "String_Node_Str" + saveMessagesDocResponse.getJSONArray("String_Node_Str").getJSONObject(0).getInt("String_Node_Str") + "String_Node_Str"+ saveMessagesDocResponse.getJSONArray("String_Node_Str").getJSONObject(0).getInt("String_Node_Str") : "String_Node_Str";
this.attachments.add(docAsAttach);
}
return this;
}