Program: 35180
Project: 35180
Buggy source:
private static void updateFile(String oldVersion,String newVersion,List<NulsVersion> versionList,URL libsUrl) throws NulsException, IOException {
  String jsonStr=null;
  try {
    jsonStr=new String(HttpDownloadUtils.download(VERDION_JSON_URL),NulsContext.DEFAULT_ENCODING);
  }
 catch (  IOException e) {
    Log.error(e);
    throw new NulsException(ErrorCode.FAILED,"String_Node_Str");
  }
  Map<String,Object> map=null;
  try {
    map=JSONUtils.json2map(jsonStr);
  }
 catch (  Exception e) {
    Log.error(e);
    throw new NulsException(ErrorCode.FAILED,"String_Node_Str");
  }
  String version=(String)map.get("String_Node_Str");
  String sign=(String)map.get("String_Node_Str");
  if (!newVersion.equals(version)) {
    start();
    return;
  }
  Map<String,String> jarMap=new HashMap<>();
  fillJarMap(libsUrl,jarMap);
  if (jarMap.isEmpty()) {
    return;
  }
  List<Map<String,Object>> libList=(List<Map<String,Object>>)map.get("String_Node_Str");
  URL rootUrl=VersionManager.class.getResource("String_Node_Str");
  File tempFolder=new File(rootUrl.getPath() + "String_Node_Str");
  if (tempFolder.exists()) {
    deleteFile(tempFolder);
  }
  tempFolder.mkdir();
  List<String> newVersionJarList=new ArrayList<>();
  for (  Map<String,Object> lib : libList) {
    String file=(String)lib.get("String_Node_Str");
    newVersionJarList.add(file);
    String libSign=(String)lib.get("String_Node_Str");
    if (jarMap.get(file) == null) {
      downloadLib(tempFolder.getPath(),file,sign);
    }
  }
  File bakFolder=new File(rootUrl.getPath() + "String_Node_Str");
  if (bakFolder.exists()) {
    deleteFile(bakFolder);
  }
  bakFolder.mkdir();
  List<String> removeList=new ArrayList<>();
  try {
    for (    String key : jarMap.keySet()) {
      if (newVersionJarList.contains(key)) {
        continue;
      }
      File jar=new File(jarMap.get(key));
      boolean b=jar.renameTo(new File(bakFolder.getPath() + "String_Node_Str" + key));
      if (!b) {
        throw new NulsException(ErrorCode.FAILED,"String_Node_Str" + key);
      }
      removeList.add(jar.getName());
    }
  }
 catch (  NulsException e) {
    List<String> failedList=new ArrayList<>();
    for (    String fileName : removeList) {
      File file=new File(bakFolder.getPath() + "String_Node_Str" + fileName);
      boolean b=file.renameTo(new File(libsUrl.getPath() + "String_Node_Str" + fileName));
      if (!b) {
        failedList.add(bakFolder.getPath() + "String_Node_Str" + fileName);
      }
    }
    failedOpration(failedList);
  }
  File[] files=tempFolder.listFiles();
  List<String> moved=new ArrayList<>();
  try {
    for (    File file : files) {
      boolean b=file.renameTo(new File(libsUrl.getPath() + "String_Node_Str" + file.getName()));
      if (!b) {
        throw new NulsException(ErrorCode.FAILED,"String_Node_Str" + file.getPath());
      }
      moved.add(file.getName());
    }
  }
 catch (  NulsException e) {
    for (    String fileName : moved) {
      File newFile=new File(libsUrl.getPath() + "String_Node_Str" + fileName);
      if (newFile.exists()) {
        newFile.delete();
      }
    }
    File[] bakFiles=bakFolder.listFiles();
    List<String> failedList=new ArrayList<>();
    for (    File file : bakFiles) {
      boolean b=file.renameTo(new File(libsUrl.getPath() + "String_Node_Str" + file.getName()));
      if (!b) {
        failedList.add(file.getPath());
      }
    }
    failedOpration(failedList);
  }
}

Fixed version (ground truth):
private static void updateFile(String oldVersion,String newVersion,List<NulsVersion> versionList,URL libsUrl) throws NulsException, IOException {
  String jsonStr=null;
  try {
    jsonStr=new String(HttpDownloadUtils.download(VERDION_JSON_URL),NulsContext.DEFAULT_ENCODING);
  }
 catch (  IOException e) {
    Log.error(e);
    throw new NulsException(ErrorCode.FAILED,"String_Node_Str");
  }
  Map<String,Object> map=null;
  try {
    map=JSONUtils.json2map(jsonStr);
  }
 catch (  Exception e) {
    Log.error(e);
    throw new NulsException(ErrorCode.FAILED,"String_Node_Str");
  }
  String version=(String)map.get("String_Node_Str");
  String sign=(String)map.get("String_Node_Str");
  if (!newVersion.equals(version)) {
    start();
    return;
  }
  Map<String,String> jarMap=new HashMap<>();
  fillJarMap(libsUrl,jarMap);
  if (jarMap.isEmpty()) {
    return;
  }
  List<Map<String,Object>> libList=(List<Map<String,Object>>)map.get("String_Node_Str");
  URL rootUrl=VersionManager.class.getResource("String_Node_Str");
  File tempFolder=new File(rootUrl.getPath() + "String_Node_Str");
  if (tempFolder.exists()) {
    deleteFile(tempFolder);
  }
  tempFolder.mkdir();
  List<String> newVersionJarList=new ArrayList<>();
  for (  Map<String,Object> lib : libList) {
    String file=(String)lib.get("String_Node_Str");
    newVersionJarList.add(file);
    String libSign=(String)lib.get("String_Node_Str");
    if (jarMap.get(file) == null) {
      downloadLib(tempFolder.getPath(),file,sign);
    }
  }
  File bakFolder=new File(rootUrl.getPath() + "String_Node_Str");
  if (bakFolder.exists()) {
    deleteFile(bakFolder);
  }
  bakFolder.mkdir();
  List<String> removeList=new ArrayList<>();
  try {
    for (    String key : jarMap.keySet()) {
      if (newVersionJarList.contains(key)) {
        continue;
      }
      File jar=new File(jarMap.get(key));
      boolean b=jar.renameTo(new File(bakFolder.getPath() + "String_Node_Str" + key));
      if (!b) {
        throw new NulsException(ErrorCode.FAILED,"String_Node_Str" + key);
      }
      removeList.add(jar.getName());
    }
  }
 catch (  NulsException e) {
    List<String> failedList=new ArrayList<>();
    for (    String fileName : removeList) {
      File file=new File(bakFolder.getPath() + "String_Node_Str" + fileName);
      boolean b=file.renameTo(new File(libsUrl.getPath() + "String_Node_Str" + fileName));
      if (!b) {
        failedList.add(bakFolder.getPath() + "String_Node_Str" + fileName);
      }
    }
    failedOpration(failedList);
  }
  File[] files=tempFolder.listFiles();
  if (files == null || files.length == 0) {
    return;
  }
  List<String> moved=new ArrayList<>();
  try {
    for (    File file : files) {
      boolean b=file.renameTo(new File(libsUrl.getPath() + "String_Node_Str" + file.getName()));
      if (!b) {
        throw new NulsException(ErrorCode.FAILED,"String_Node_Str" + file.getPath());
      }
      moved.add(file.getName());
    }
  }
 catch (  NulsException e) {
    for (    String fileName : moved) {
      File newFile=new File(libsUrl.getPath() + "String_Node_Str" + fileName);
      if (newFile.exists()) {
        newFile.delete();
      }
    }
    File[] bakFiles=bakFolder.listFiles();
    List<String> failedList=new ArrayList<>();
    for (    File file : bakFiles) {
      boolean b=file.renameTo(new File(libsUrl.getPath() + "String_Node_Str" + file.getName()));
      if (!b) {
        failedList.add(file.getPath());
      }
    }
    failedOpration(failedList);
  }
}