Source:
private void callWebHook(IssueChangeData issueChangeData) { Set<String> componentUuids = issueChangeData.getIssues().stream() .map(DefaultIssue::projectUuid) .collect(toSet()); try (DbSession dbSession = dbClient.openSession(false)) { Map<String, ComponentDto> branchesByUuid = getBranchComponents(dbSession, componentUuids, issueChangeData); if (branchesByUuid.isEmpty()) { return; } Set<String> branchProjectUuids = branchesByUuid.values().stream() .map(ComponentDto::uuid) .collect(toSet(branchesByUuid.size())); Set<BranchDto> shortBranches = dbClient.branchDao().selectByUuids(dbSession, branchProjectUuids) .stream() .filter(branchDto -> branchDto.getBranchType() == BranchType.SHORT) .collect(toSet(branchesByUuid.size())); if (shortBranches.isEmpty()) { return; } Map<String, Configuration> configurationByUuid = projectConfigurationLoader.loadProjectConfigurations(dbSession, shortBranches.stream().map(shortBranch -> branchesByUuid.get(shortBranch.getUuid())).collect(Collectors.toSet())); Set<BranchDto> branchesWithWebhooks = shortBranches.stream() .filter(shortBranch -> webhooks.isEnabled(configurationByUuid.get(shortBranch.getUuid()))) .collect(toSet()); if (branchesWithWebhooks.isEmpty()) { return; } Map<String, SnapshotDto> analysisByProjectUuid = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids( dbSession, branchesWithWebhooks.stream().map(BranchDto::getUuid).collect(toSet(shortBranches.size()))) .stream() .collect(uniqueIndex(SnapshotDto::getComponentUuid)); branchesWithWebhooks .forEach(shortBranch -> { ComponentDto branch = branchesByUuid.get(shortBranch.getUuid()); SnapshotDto analysis = analysisByProjectUuid.get(shortBranch.getUuid()); if (branch != null && analysis != null) { webhooks.sendProjectAnalysisUpdate( configurationByUuid.get(shortBranch.getUuid()), new WebHooks.Analysis(shortBranch.getUuid(), analysis.getUuid(), null), () -> buildWebHookPayload(dbSession, branch, shortBranch, analysis)); } }); } }

Target:
private void callWebHook(IssueChangeData issueChangeData) { try (DbSession dbSession = dbClient.openSession(false)) { Map<String, ComponentDto> branchesByUuid = getBranchComponents(dbSession, issueChangeData); if (branchesByUuid.isEmpty()) { return; } Set<String> branchProjectUuids = branchesByUuid.values().stream() .map(ComponentDto::uuid) .collect(toSet(branchesByUuid.size())); Set<BranchDto> shortBranches = dbClient.branchDao().selectByUuids(dbSession, branchProjectUuids) .stream() .filter(branchDto -> branchDto.getBranchType() == BranchType.SHORT) .collect(toSet(branchesByUuid.size())); if (shortBranches.isEmpty()) { return; } Map<String, Configuration> configurationByUuid = projectConfigurationLoader.loadProjectConfigurations(dbSession, shortBranches.stream().map(shortBranch -> branchesByUuid.get(shortBranch.getUuid())).collect(Collectors.toSet())); Set<BranchDto> branchesWithWebhooks = shortBranches.stream() .filter(shortBranch -> webhooks.isEnabled(configurationByUuid.get(shortBranch.getUuid()))) .collect(toSet()); if (branchesWithWebhooks.isEmpty()) { return; } Map<String, SnapshotDto> analysisByProjectUuid = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids( dbSession, branchesWithWebhooks.stream().map(BranchDto::getUuid).collect(toSet(shortBranches.size()))) .stream() .collect(uniqueIndex(SnapshotDto::getComponentUuid)); branchesWithWebhooks .forEach(shortBranch -> { ComponentDto branch = branchesByUuid.get(shortBranch.getUuid()); SnapshotDto analysis = analysisByProjectUuid.get(shortBranch.getUuid()); if (branch != null && analysis != null) { webhooks.sendProjectAnalysisUpdate( configurationByUuid.get(shortBranch.getUuid()), new WebHooks.Analysis(shortBranch.getUuid(), analysis.getUuid(), null), () -> buildWebHookPayload(dbSession, branch, shortBranch, analysis)); } }); } }