Program: 141967
Project: 141967
Buggy source:
@Override public boolean install(Resource r,ResourceLocation location,Reference ref,ResourceTable table,AndroidCommCarePlatform platform,boolean upgrade) throws UnresolvedResourceException, UnfullfilledRequirementsException {
  try {
    InputStream inputFileStream;
    try {
      inputFileStream=ref.getStream();
    }
 catch (    FileNotFoundException e) {
      return false;
    }
    File tempFile=new File(CommCareApplication.instance().getTempFilePath());
    Reference localReference;
    OutputStream outputFileStream;
    try {
      Pair<String,String> fileNameAndExt=getResourceName(r,location);
      String referenceRoot=upgrade ? upgradeDestination : localDestination;
      localReference=getEmptyLocalReference(referenceRoot,fileNameAndExt.first,fileNameAndExt.second);
      outputFileStream=new FileOutputStream(tempFile);
      localLocation=localReference.getURI();
    }
 catch (    InvalidReferenceException ire) {
      throw new LocalStorageUnavailableException("String_Node_Str" + localLocation + "String_Node_Str",localLocation);
    }
catch (    IOException ioe) {
      throw new LocalStorageUnavailableException("String_Node_Str" + localLocation + "String_Node_Str",localLocation);
    }
    StreamsUtil.writeFromInputToOutputNew(inputFileStream,outputFileStream);
    renameFile(localReference.getLocalURI(),tempFile);
    int status=customInstall(r,localReference,upgrade);
    table.commit(r,status);
    if (localLocation == null) {
      throw new UnresolvedResourceException(r,"String_Node_Str");
    }
    return true;
  }
 catch (  SSLHandshakeException|SSLPeerUnverifiedException e) {
    e.printStackTrace();
    UnresolvedResourceException mURE=new UnresolvedResourceException(r,"String_Node_Str",true);
    mURE.initCause(e);
    throw mURE;
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new UnreliableSourceException(r,e.getMessage());
  }
}

Fixed version (ground truth):
@Override public boolean install(Resource r,ResourceLocation location,Reference ref,ResourceTable table,AndroidCommCarePlatform platform,boolean upgrade) throws UnresolvedResourceException, UnfullfilledRequirementsException {
  try {
    InputStream inputFileStream;
    try {
      inputFileStream=ref.getStream();
    }
 catch (    FileNotFoundException e) {
      return false;
    }
    File tempFile=new File(CommCareApplication.instance().getTempFilePath());
    Reference localReference;
    OutputStream outputFileStream;
    try {
      Pair<String,String> fileNameAndExt=getResourceName(r,location);
      String referenceRoot=upgrade ? upgradeDestination : localDestination;
      localReference=getEmptyLocalReference(referenceRoot,fileNameAndExt.first,fileNameAndExt.second);
      outputFileStream=new FileOutputStream(tempFile);
      localLocation=localReference.getURI();
    }
 catch (    InvalidReferenceException ire) {
      throw new LocalStorageUnavailableException("String_Node_Str" + localLocation + "String_Node_Str",localLocation);
    }
catch (    IOException ioe) {
      throw new LocalStorageUnavailableException("String_Node_Str" + localLocation + "String_Node_Str",localLocation);
    }
    StreamsUtil.writeFromInputToOutputNew(inputFileStream,outputFileStream);
    renameFile(localReference.getLocalURI(),tempFile);
    int status=customInstall(r,localReference,upgrade,platform);
    table.commit(r,status);
    if (localLocation == null) {
      throw new UnresolvedResourceException(r,"String_Node_Str");
    }
    return true;
  }
 catch (  SSLHandshakeException|SSLPeerUnverifiedException e) {
    e.printStackTrace();
    UnresolvedResourceException mURE=new UnresolvedResourceException(r,"String_Node_Str",true);
    mURE.initCause(e);
    throw mURE;
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new UnreliableSourceException(r,e.getMessage());
  }
}