-
-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallel invocation of DetektFacade fails spuriously #2433
Comments
I still see this even with 1.7.1 on gradle projects |
Has someone an open repository where this is like 1/10 reliably reproducable? |
Ours is private but I'm happy to run any debugging steps if it helps |
I could not reproduce a crash with current master. package io.gitlab.arturbosch.detekt.core
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import java.util.concurrent.Executors
import java.util.concurrent.Future
internal class ProcessingSettingsTest : Spek({
describe("runs") {
it("bla") {
val service = Executors.newFixedThreadPool(4)
val futures = mutableListOf<Future<*>>()
for (_i in (0..1000)) {
val future = service.submit {
val settings = ProcessingSettings(
emptyList(),
outPrinter = System.out,
errPrinter = System.err
)
val facade = DetektFacade.create(settings)
facade.run()
}
futures.add(future)
}
futures.forEach { it.get() }
}
}
}) @ZacSweers @davidburstrom please test it again with 1.7.2 |
I've tried removing my workaround (external synchronization) and tried my compatibility test suite with 1.6.0, 1.7.0, 1.7.1 and 1.7.2. I was only able to reproduce the bug on 1.6.0, about 1 out of 3 runs, and never on 1.7.0+. My guess is that it's a similar but different issue for @ZacSweers? |
1.7.2 works for us 👍 |
Expected Behavior
It should be possible to run tests and other scenarios in parallel where DetectFacade is invoked.
Observed Behavior
As reported in e.g. Ozsie/detekt-maven-plugin#34, parallel execution can fail. A typical stack trace is
Steps to Reproduce
Reproduction could be provided if requested.
Context
Looking at the implementation of
DetektPomModel
(https://github.com/arturbosch/detekt/blob/2f7859844a8eefc05a0e58a4e551dac143a58a8e/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/internal/DetektPomModel.kt#L26) it looks like there is an attempt not to dual-register the extension point. However, this faces race conditions, where two threads may see that the singleton null/root area does not have the EP registered, and then attempts to register the EP in parallel.Your Environment
The text was updated successfully, but these errors were encountered: