Program: 188674
Project: 188674
Buggy source:
public RiskIncidence addRiskIncidence(String riskId,String aipId,String representationId,List<String> fileDirectoryPath,String fileId,String type) throws GenericException {
  RiskIncidence riskIncidence=null;
  String fileSuffix=RodaConstants.RISK_INCIDENCE_FILE_EXTENSION;
  try {
    Binary incidenceBinary=this.retrieveOtherMetadataBinary(aipId,representationId,fileDirectoryPath,fileId,fileSuffix,type);
    InputStream inputStream=incidenceBinary.getContent().createInputStream();
    riskIncidence=JsonUtils.getObjectFromJson(inputStream,RiskIncidence.class);
    IOUtils.closeQuietly(inputStream);
    if (riskIncidence.getRisks().contains(riskId)) {
      return riskIncidence;
    }
  }
 catch (  NotFoundException|IOException|RequestNotValidException|AuthorizationDeniedException e) {
    riskIncidence=new RiskIncidence();
    riskIncidence.setId(UUID.randomUUID().toString());
    if (fileId != null) {
      riskIncidence.setObjectId(fileId);
    }
 else     if (representationId != null) {
      riskIncidence.setObjectId(representationId);
    }
 else {
      riskIncidence.setObjectId(aipId);
    }
  }
  try {
    riskIncidence.addRisk(riskId);
    String riskIncidenceAsJson=JsonUtils.getJsonFromObject(riskIncidence);
    this.createOtherMetadata(aipId,representationId,fileDirectoryPath,fileId,fileSuffix,type,new StringContentPayload(riskIncidenceAsJson),true);
    notifyRiskIncidenceCreatedOrUpdated(riskIncidence);
  }
 catch (  RequestNotValidException|NotFoundException|AuthorizationDeniedException e) {
    LOGGER.error("String_Node_Str",e);
  }
  return riskIncidence;
}

Fixed version (ground truth):
public RiskIncidence addRiskIncidence(String riskId,String aipId,String representationId,List<String> fileDirectoryPath,String fileId,String type) throws GenericException {
  RiskIncidence riskIncidence=null;
  String fileSuffix=RodaConstants.RISK_INCIDENCE_FILE_EXTENSION;
  try {
    Binary incidenceBinary=this.retrieveOtherMetadataBinary(aipId,representationId,fileDirectoryPath,fileId,fileSuffix,type);
    InputStream inputStream=incidenceBinary.getContent().createInputStream();
    riskIncidence=JsonUtils.getObjectFromJson(inputStream,RiskIncidence.class);
    IOUtils.closeQuietly(inputStream);
    if (riskIncidence.getRisks().contains(riskId)) {
      return riskIncidence;
    }
  }
 catch (  NotFoundException|IOException|RequestNotValidException|AuthorizationDeniedException e) {
    riskIncidence=new RiskIncidence();
    riskIncidence.setId(UUID.randomUUID().toString());
    if (fileId != null) {
      riskIncidence.setObjectId(fileId);
      riskIncidence.setObjectClass(File.class.getSimpleName());
    }
 else     if (representationId != null) {
      riskIncidence.setObjectId(representationId);
      riskIncidence.setObjectClass(Representation.class.getSimpleName());
    }
 else {
      riskIncidence.setObjectId(aipId);
      riskIncidence.setObjectClass(AIP.class.getSimpleName());
    }
  }
  try {
    riskIncidence.addRisk(riskId);
    String riskIncidenceAsJson=JsonUtils.getJsonFromObject(riskIncidence);
    this.createOtherMetadata(aipId,representationId,fileDirectoryPath,fileId,fileSuffix,type,new StringContentPayload(riskIncidenceAsJson),true);
    notifyRiskIncidenceCreatedOrUpdated(riskIncidence,true);
  }
 catch (  RequestNotValidException|NotFoundException|AuthorizationDeniedException e) {
    LOGGER.error("String_Node_Str",e);
  }
  return riskIncidence;
}