Skip to content

Commit 02e0364

Browse files
committed
Large parallel builds could throw ConcurrentModificationException, fixes #1015.
1 parent b66935e commit 02e0364

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

plugin-gradle/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
66
### Fixed
77
* Spotless no longer applies `BasePlugin` ([#1014](https://github.com/diffplug/spotless/pull/1014)).
88
* This was done to ensure that any Spotless tasks would run after the `clean` task, but we found a way to do this without applying the `BasePlugin`. This resolves a conflict with the [Android Gradle template](https://issuetracker.google.com/issues/186924459) (fixes [#858](https://github.com/diffplug/spotless/issues/858)).
9+
* Large parallel builds could throw `ConcurrentModificationException` (masked by "Cannot add a configuration with name"), now fixed. ([#1015](https://github.com/diffplug/spotless/issues/1015))
910

1011
## [6.0.2] - 2021-12-05
1112
### Changed

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,16 @@ protected void setupTask(SpotlessTask task) {
757757
} else {
758758
steps = this.steps;
759759
}
760+
// <IMPORTANT>
761+
// By calling .hashCode, we are triggering all steps to evaluate their state,
762+
// which triggers dependency resolution. It's important to do that here, because
763+
// otherwise it won't happen until Gradle starts checking for task up-to-date-ness.
764+
// For a large parallel build, the task up-to-dateness might get called on a different
765+
// thread than the thread where task configuration happens, which will trigger a
766+
// java.util.ConcurrentModificationException
767+
// See https://github.com/diffplug/spotless/issues/1015 for details.
768+
steps.hashCode();
769+
// </IMPORTANT>
760770
task.setSteps(steps);
761771
task.setLineEndingsPolicy(getLineEndings().createPolicy(getProject().getProjectDir(), () -> totalTarget));
762772
spotless.getRegisterDependenciesTask().hookSubprojectTask(task);

0 commit comments

Comments
 (0)