Don't let getSession cause an infinite loop if it throws IllegalStateException #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #215
I have implemented this as a monkeypatch to our system and verified the infinite loop goes away for us, and figured it would be useful to submit this upstream.
I break the infinite loop by catching the
IllegalStateException
when caused bygetSession(boolean)
and throw it as aRuntimeError
to avoid triggering the loop.This might be better solved by restructuring the code, or changing what the begin/rescue is wrapping, or preventing infinite retries, but I patched this in our system like this to avoid making too much changes to the original code and possibly introducing a different bug.
Please let me know if you would like me to attempt a different approach.