Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2427.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: Fix ConcurrentModificationExceptions thrown from BaselineNullAway
links:
- https://github.com/palantir/gradle-baseline/pull/2427
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void execute(Configuration _files) {

private static boolean anyProjectUsesJava15(Project proj) {
return proj.getAllprojects().stream()
.anyMatch(project -> project.getTasks().withType(JavaCompile.class).stream()
.anyMatch(project -> ImmutableList.copyOf(project.getTasks().withType(JavaCompile.class)).stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we would be better off replacing the Collection.stream() here using something along these lines:

project.getTasks().withType(JavaCompile.class).matching(comp -> {
  JavaVersion javaVersion = JavaVersion.toVersion(comp.getTargetCompatibility());
  return javaVersion == JavaVersion.VERSION_15;
}).isEmpty()

I suspect the TaskContainer may be a bit smarter about modification within iteration when it controls the iteration rather than returning a stream wrapping a spliterator, but it's difficult to say without a reliable reproducer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this by testing gw classes --stacktrace on my internal failing repo, and that command:

  • fails on com.palantir.baseline:gradle-baseline-java:4.180.0
  • succeeds on com.palantir.baseline:gradle-baseline-java:4.180.0-8-ga477298
  • fails on com.palantir.baseline:gradle-baseline-java:4.180.0-9-g05114a5

So I think the ImmutableList copy approach works and the TaskCollection one doesn't. At least it gets these runs to pass.

.anyMatch(comp -> {
JavaVersion javaVersion = JavaVersion.toVersion(comp.getTargetCompatibility());
return javaVersion == JavaVersion.VERSION_15;
Expand Down