Skip to content

Commit

Permalink
Convert Java8 stream to For loop, since it's not compatible with TC9
Browse files Browse the repository at this point in the history
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
  • Loading branch information
netwolfuk committed May 3, 2020
1 parent 2e06a5c commit 3558e25
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -82,11 +82,13 @@ private ProjectWebhook getWebHookConfigById(String projectExternalId, final Fiel
}

public Collection<String> getBuildTypeExternalIds(Collection<String> 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<String> externalExternalIds = new ArrayList<>();
for (String internalId : internalIds) {
if (this.projectManager.findBuildTypeById(internalId) != null) {
externalExternalIds.add(this.projectManager.findBuildTypeById(internalId).getExternalId());
}
}
return externalExternalIds;
}
}

0 comments on commit 3558e25

Please sign in to comment.