Skip to content
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

Wrap all javaparser getType calls in Try #4666

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

johannescoetzee
Copy link
Contributor

@johannescoetzee johannescoetzee commented Jun 13, 2024

Related to #4665

The AstCreator is crashing on a customer project due to an UnsolvedSymbolException. As mentioned in the PR, there isn't enough information in the logs to locate the exact issue, but my theory is that it is due to a getType call somewhere. For this PR, I've wrapped all getType calls in a Try (unless they were already wrapped) since the JavaParser symbol solver and the interactions between the various kinds of solvers are too complex to easily tell when these calls should be safe and when not.

Revision 2: I've changed Try to tryWithSafeStackOverflow, which also logs stack traces for errors now. This isn't called during regular type resolution, so we won't log every failed type (since those are often to be expected), but we should keep an eye on javasrc log sizes and more selectively log these if it turns out to be too much

case failure: Failure[_] =>
val exceptionType = failure.exception.getClass

val shouldLog = loggedExceptionCounts.get(exceptionType) match {
Copy link
Contributor

Choose a reason for hiding this comment

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

You will need to use an atomic read + update operation on the concurrent map. Like this the code is not thread safe.

@johannescoetzee johannescoetzee merged commit a65a3b2 into master Jun 14, 2024
5 checks passed
@johannescoetzee johannescoetzee deleted the johannes/javasrc-safe-get-type branch June 14, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants