-
-
Notifications
You must be signed in to change notification settings - Fork 774
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
Fix IgnoredReturnValue rule crash in parallel mode #5413
Conversation
IgnoredReturnValue crashes due to the usage of a non-thread-safe collection operation. The usage of `Iterable<T>.plus()` causes this problem. The crash in parallel mode is fixed by iterating over each collection by itself. See here for more details in detekt v1.21: https://github.com/detekt/detekt/blob/32f6e22d9524804ebbb51d31e53cd28a84864ed6/detekt-rules-errorprone/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValue.kt#L90 Closes #5403
I also checked with find usages whether detekt's code base contains related issues. No further issues have been found. The questions is how we can prevent issues like this happening again in parallel mode. |
We do have ConTester in the codebase. @davidburstromspotify helped up set it up. |
@cortinico my question aimed for preventing such issues in general in the future. I’m not sure how a potential solution for a test could like. |
@cortinico ConTester unfortunately doesn't give you the required granular control in methods that are getting invoked, only in your own method implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insights. I think we're safe shipping this specific fix. As for preventing those kind of issues in the future, other than stress testing our rules with --parallel
on CI, I don't have other ideas 🤔
I like your idea. It is worthwhile to proceed. 👍 |
Still interesting that the line of code causing this crash was introduced 15 months ago and that only a few days the first issue appeared pointing to this line of code. |
I'm still puzzled by why that code is not parallel safe. Those are list provided by the PSI. Are those list changing? Is this related with the auto-correct feature? |
I'm guessing wildly here, but if I read the stack trace correctly, the |
IgnoredReturnValue crashes due to the usage of a non-thread-safe collection operation. The usage of
Iterable<T>.plus()
causes this problem. The crash in parallel mode is fixed by iterating over each collection by itself.See here for more details in detekt v1.21:
detekt/detekt-rules-errorprone/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValue.kt
Line 90 in 32f6e22
Closes #5403