Source:
<code>public Optional<Resource> getUsedResource(String accountId) throws NotFoundException, ServerException { final Account account = accountManager.getById(accountId); List<WorkspaceImpl> activeWorkspaces = Pages.stream( (maxItems, skipCount) -> workspaceManagerProvider .get() .getByNamespace(account.getName(), true, maxItems, skipCount)) .filter(ws -> STOPPED != ws.getStatus()) .collect(Collectors.toList()); long currentlyUsedRamMB = 0; for (WorkspaceImpl activeWorkspace : activeWorkspaces) { if (WorkspaceStatus.STARTING.equals(activeWorkspace.getStatus())) { WorkspaceConfigImpl config = activeWorkspace.getConfig(); if (config != null) { final EnvironmentImpl startingEnvironment = config.getEnvironments().get(activeWorkspace.getRuntime().getActiveEnv()); if (startingEnvironment != null) { currentlyUsedRamMB += environmentRamCalculator.calculate(startingEnvironment); } if (SidecarToolingWorkspaceUtil.isSidecarBasedWorkspace(config.getAttributes())) { LOG.warn( <START> "Sidecar based workspace `{}` is starting, memory of its plugins is not taken in " <END> + "account while workspace is starting. Set memory resources limits may work incorrectly"); } } else { LOG.warn( "Devfile based workspace `{}` is starting, its memory is not taken in account " + "while workspace is starting. Set memory resources limits may work incorrectly"); } } else { currentlyUsedRamMB += environmentRamCalculator.calculate(activeWorkspace.getRuntime()); } } if (currentlyUsedRamMB > 0) { return Optional.of( new ResourceImpl(RamResourceType.ID, currentlyUsedRamMB, RamResourceType.UNIT)); } else { return Optional.empty(); } }</code><technical_language>"Memory consumption of a plugin in a sidecar-based workspace is account while workspace is starting. memory limits applied correctly."</technical_language>

Target:
public Optional<Resource> getUsedResource(String accountId) throws NotFoundException, ServerException { final Account account = accountManager.getById(accountId); List<WorkspaceImpl> activeWorkspaces = Pages.stream( (maxItems, skipCount) -> workspaceManagerProvider .get() .getByNamespace(account.getName(), true, maxItems, skipCount)) .filter(ws -> STOPPED != ws.getStatus()) .collect(Collectors.toList()); long currentlyUsedRamMB = 0; for (WorkspaceImpl activeWorkspace : activeWorkspaces) { if (WorkspaceStatus.STARTING.equals(activeWorkspace.getStatus())) { WorkspaceConfigImpl config = activeWorkspace.getConfig(); if (config != null) { final EnvironmentImpl startingEnvironment = config.getEnvironments().get(activeWorkspace.getRuntime().getActiveEnv()); if (startingEnvironment != null) { currentlyUsedRamMB += environmentRamCalculator.calculate(startingEnvironment); } if (SidecarToolingWorkspaceUtil.isSidecarBasedWorkspace(config.getAttributes())) { LOG.warn( "Memory consumption of plugins in a sidecar-based workspace `{}` is not taken" + " into account while the workspace is starting. The memory limits may not be" + " applied correctly."); } } else { LOG.warn( "Memory consumption is not taken into account while a devfile-based workspace" + " `{}` is starting. The memory limits may not be applied correctly."); } } else { currentlyUsedRamMB += environmentRamCalculator.calculate(activeWorkspace.getRuntime()); } } if (currentlyUsedRamMB > 0) { return Optional.of( new ResourceImpl(RamResourceType.ID, currentlyUsedRamMB, RamResourceType.UNIT)); } else { return Optional.empty(); } }