Program: 62396
Project: 62396
Buggy source:
/** 
 * Upload a plugin from a given path.
 * @param uploadedPluginPath The path of the plugin to upload.
 * @throws IOException In case there is an issue with the access to the plugin file.
 * @throws PluginLoadingException
 * @throws AlreadyExistException if a plugin with the same id already exists in the repository
 * @return the uploaded plugin
 * @throws MissingPlugingDescriptorFileException
 */
public Plugin uploadPlugin(Path uploadedPluginPath) throws PluginLoadingException, IOException, MissingPlugingDescriptorFileException {
  FileSystem fs=FileSystems.newFileSystem(uploadedPluginPath,null);
  PluginDescriptor descriptor=null;
  try {
    try {
      descriptor=YamlParserUtil.parseFromUTF8File(fs.getPath(PLUGIN_DESCRIPTOR_FILE),PluginDescriptor.class);
    }
 catch (    IOException e) {
      if (e instanceof NoSuchFileException) {
        throw new MissingPlugingDescriptorFileException();
      }
 else {
        throw e;
      }
    }
    String pluginPathId=getPluginPathId();
    Plugin plugin=new Plugin(descriptor,pluginPathId);
    Path pluginPath=getPluginPath(pluginPathId);
    FileUtil.unzip(uploadedPluginPath,pluginPath);
    Path pluginUiSourcePath=pluginPath.resolve(UI_DIRECTORY);
    Path pluginUiPath=getPluginUiPath(pluginPathId);
    if (Files.exists(pluginUiSourcePath)) {
      FileUtil.copy(pluginUiSourcePath,pluginUiPath);
    }
    long count=alienDAO.count(Plugin.class,QueryBuilders.idsQuery(MappingBuilder.indexTypeFromClass(Plugin.class)).ids(plugin.getId()));
    if (count > 0) {
      log.warn("String_Node_Str",plugin.getId());
      throw new AlreadyExistException("String_Node_Str");
    }
    loadPlugin(plugin);
    plugin.setConfigurable(isPluginConfigurable(plugin.getId()));
    alienDAO.save(plugin);
    log.info("String_Node_Str" + plugin.getId() + "String_Node_Str");
    return plugin;
  }
  finally {
    fs.close();
  }
}

Fixed version (ground truth):
/** 
 * Upload a plugin from a given path.
 * @param uploadedPluginPath The path of the plugin to upload.
 * @throws IOException In case there is an issue with the access to the plugin file.
 * @throws PluginLoadingException
 * @throws AlreadyExistException if a plugin with the same id already exists in the repository
 * @return the uploaded plugin
 * @throws MissingPlugingDescriptorFileException
 */
public Plugin uploadPlugin(Path uploadedPluginPath) throws PluginLoadingException, IOException, MissingPlugingDescriptorFileException {
  FileSystem fs=FileSystems.newFileSystem(uploadedPluginPath,null);
  PluginDescriptor descriptor=null;
  try {
    try {
      descriptor=YamlParserUtil.parseFromUTF8File(fs.getPath(PLUGIN_DESCRIPTOR_FILE),PluginDescriptor.class);
    }
 catch (    IOException e) {
      if (e instanceof NoSuchFileException) {
        throw new MissingPlugingDescriptorFileException();
      }
 else {
        throw e;
      }
    }
    String pluginPathId=getPluginPathId();
    Plugin plugin=new Plugin(descriptor,pluginPathId);
    long count=alienDAO.count(Plugin.class,QueryBuilders.idsQuery(MappingBuilder.indexTypeFromClass(Plugin.class)).ids(plugin.getId()));
    if (count > 0) {
      log.warn("String_Node_Str",plugin.getId());
      throw new AlreadyExistException("String_Node_Str");
    }
    Path pluginPath=getPluginPath(pluginPathId);
    FileUtil.unzip(uploadedPluginPath,pluginPath);
    Path pluginUiSourcePath=pluginPath.resolve(UI_DIRECTORY);
    Path pluginUiPath=getPluginUiPath(pluginPathId);
    if (Files.exists(pluginUiSourcePath)) {
      FileUtil.copy(pluginUiSourcePath,pluginUiPath);
    }
    loadPlugin(plugin);
    plugin.setConfigurable(isPluginConfigurable(plugin.getId()));
    alienDAO.save(plugin);
    log.info("String_Node_Str" + plugin.getId() + "String_Node_Str");
    return plugin;
  }
  finally {
    fs.close();
  }
}