Source:
public List<GoDashboardPipeline> allPipelines(CruiseConfig config) { List<CaseInsensitiveString> allPipelineNames = config.getAllPipelineNames(); HashSet<CaseInsensitiveString> newPipelineNames = new HashSet<>(allPipelineNames); if (!newPipelineNames.equals(previousPipelineNames)) { List<String> pipelineNames = CaseInsensitiveString.toStringList(allPipelineNames); historyForDashboard = loadHistoryForPipelines(pipelineNames); previousPipelineNames = newPipelineNames; } LOGGER.debug("Loading permissions from authority"); final Map<CaseInsensitiveString, Permissions> pipelinesAndTheirPermissions = permissionsAuthority.pipelinesAndTheirPermissions(); final List<GoDashboardPipeline> pipelines = new ArrayList<>(1024); LOGGER.debug("Populating dashboard pipelines"); config.accept(new PipelineGroupVisitor() { @Override public void visit(final PipelineConfigs group) { group.accept(new PiplineConfigVisitor() { @Override public void visit(PipelineConfig pipelineConfig) { long start = System.currentTimeMillis(); Permissions permissions = permissionsFor(pipelineConfig, pipelinesAndTheirPermissions); pipelines.add(createGoDashboardPipeline(pipelineConfig, permissions, historyForDashboard, group)); LOGGER.debug("It took {}ms to process pipeline {}", (System.currentTimeMillis() - start), pipelineConfig.getName()); } }); } }); LOGGER.debug("Done populating dashboard pipelines"); this.everLoadedCurrentState = true; return pipelines; }

Target:
public List<GoDashboardPipeline> allPipelines(CruiseConfig config) { List<CaseInsensitiveString> allPipelineNames = config.getAllPipelineNames(); HashSet<CaseInsensitiveString> newPipelineNames = new HashSet<>(allPipelineNames); Collection<CaseInsensitiveString> pipelinesToRemove = Sets.difference(previousPipelineNames, newPipelineNames); Collection<CaseInsensitiveString> pipelinesToAdd = Sets.difference(newPipelineNames, previousPipelineNames); if (!pipelinesToAdd.isEmpty()) { historyForDashboard.addAll(loadHistoryForPipelines(new ArrayList<>(CaseInsensitiveString.toStringList(pipelinesToAdd)))); } for (CaseInsensitiveString pipelineNameToRemove : pipelinesToRemove) { historyForDashboard.removeIf(new Predicate<PipelineInstanceModel>() { @Override public boolean test(PipelineInstanceModel pipelineInstanceModel) { return pipelineNameToRemove.equals(new CaseInsensitiveString(pipelineInstanceModel.getName())); } }); } previousPipelineNames = newPipelineNames; LOGGER.debug("Loading permissions from authority"); final Map<CaseInsensitiveString, Permissions> pipelinesAndTheirPermissions = permissionsAuthority.pipelinesAndTheirPermissions(); final List<GoDashboardPipeline> pipelines = new ArrayList<>(1024); LOGGER.debug("Populating dashboard pipelines"); config.accept(new PipelineGroupVisitor() { @Override public void visit(final PipelineConfigs group) { group.accept(new PiplineConfigVisitor() { @Override public void visit(PipelineConfig pipelineConfig) { long start = System.currentTimeMillis(); Permissions permissions = permissionsFor(pipelineConfig, pipelinesAndTheirPermissions); pipelines.add(createGoDashboardPipeline(pipelineConfig, permissions, historyForDashboard, group)); LOGGER.debug("It took {}ms to process pipeline {}", (System.currentTimeMillis() - start), pipelineConfig.getName()); } }); } }); LOGGER.debug("Done populating dashboard pipelines"); this.everLoadedCurrentState = true; return pipelines; }