code: public boolean updatePlugin(String id, String version) throws PluginException {
          if (pluginManager.getPlugin(id) == null) {
              throw new PluginException("Plugin {} cannot be updated since it is not installed", id);
          }
  
          PluginInfo pluginInfo = getPluginsMap().get(id);
          if (pluginInfo == null) {
              throw new PluginException("Plugin {} does not exist in any repository", id);
          }
  
          if (!hasPluginUpdate(id)) {
              log.warn("Plugin {} does not have an update available which is compatible with system version", id, systemVersion);
              return false;
          }
  
          // Download to temp folder
          Path downloaded = downloadPlugin(id, version);
  
          if (!pluginManager.deletePlugin(id)) {
              return false;
          }
  
          Path pluginsRoot = pluginManager.getPluginsRoot();
          Path file = pluginsRoot.resolve(downloaded.getFileName());
          try {
              Files.move(downloaded, file);
          } catch (IOException e) {
              throw new PluginException("Failed to write plugin file {} to plugin folder", file);
          }
  
          String newPluginId = pluginManager.loadPlugin(file);
          PluginState state = pluginManager.startPlugin(newPluginId);
  
          return PluginState.STARTED.equals(state);
      }
docs: Updates a plugin id to given version or to latest version if {@code version == null}.
  
  @param id the id of plugin to update
  @param version the version to update to, on SemVer format, or null for latest
  @return true if update successful
  @exception PluginException in case the given version is not available, plugin id not already installed etc