-
Notifications
You must be signed in to change notification settings - Fork 503
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
ktlint hangs under certain conditions #277
Comments
@blindpirate thank you for such a detailed issue! I added a few comments (in addition to fixing the root cause) that should (hopefully) clarify the intent -https://github.com/shyiko/ktlint/blob/44fd18ccdd29b80a8aaa5301455c662c0d702532/ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt#L736-L794. Regarding blindpirate@14f37fd: Fixed in 0.28.0. |
Thank you so much for such a quick response! |
Context
Recently, we (Gradle core team) observed some of our builds hang forever at this position:
I did some investigation and it seems like the current
Main.parallel()
implementation is not robust enough. Under certain conditions, it might hang forever.Step to reproduce
I created a simple sample to reproduce it: blindpirate@cb161d0
Run the
main
method you can see the process hangs. Runjstack
on the process you can see the process hangs at the exactly same position as the stacktrace above.Analysis
When there're much more tasks than
numberOfThreads
and this line throws an exception,ArrayBlockingQueue.put()
method may block forever because the consumer thread has already finished. Since the exception gets no chance to be rethrown, users can't see it at stderr and don't know what's happening there.Possible solution
I don't know why ktlint uses such a complicated
parallel
implementation, can't we make it simpler, like blindpirate@14f37fd ?The text was updated successfully, but these errors were encountered: