From 3558e25a54ea52b62f2859203cd5c71a99d28493 Mon Sep 17 00:00:00 2001 From: Net Wolf UK Date: Sun, 3 May 2020 21:35:04 +1200 Subject: [PATCH] Convert Java8 stream to For loop, since it's not compatible with TC9 TeamCity 9.x using Jersey 1.16, and asm 3.1 ASM 3.1, only supports Java7, so we can't use Java8 streams and such in the REST API if we want to support TeamCity 9. It appears that since TC10, Jetbrains have moved to using Jersey 1.19, and a newer version of ASM which supports Java 8. This is why this was never seen on TC10 and above. Fixes #156 --- .../server/rest/data/WebHookFinder.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tcwebhooks-rest-api/src/main/java/webhook/teamcity/server/rest/data/WebHookFinder.java b/tcwebhooks-rest-api/src/main/java/webhook/teamcity/server/rest/data/WebHookFinder.java index 111049a0..7b98cc53 100644 --- a/tcwebhooks-rest-api/src/main/java/webhook/teamcity/server/rest/data/WebHookFinder.java +++ b/tcwebhooks-rest-api/src/main/java/webhook/teamcity/server/rest/data/WebHookFinder.java @@ -1,8 +1,8 @@ package webhook.teamcity.server.rest.data; +import java.util.ArrayList; import java.util.Collection; -import java.util.Objects; -import java.util.stream.Collectors; +import java.util.List; import org.jetbrains.annotations.NotNull; @@ -82,11 +82,13 @@ private ProjectWebhook getWebHookConfigById(String projectExternalId, final Fiel } public Collection getBuildTypeExternalIds(Collection internalIds) { - return internalIds.stream() - .filter(id -> - Objects.nonNull(this.projectManager.findBuildTypeById(id)) - && Objects.nonNull(this.projectManager.findBuildTypeById(id).getExternalId())) - .map(id -> this.projectManager.findBuildTypeById(id).getExternalId()) - .collect(Collectors.toList()); + // Don't use Java8 streams. They don't work with Jersey 1.16 (TC9.x) + List externalExternalIds = new ArrayList<>(); + for (String internalId : internalIds) { + if (this.projectManager.findBuildTypeById(internalId) != null) { + externalExternalIds.add(this.projectManager.findBuildTypeById(internalId).getExternalId()); + } + } + return externalExternalIds; } }