JetBrainsRuntime
JetBrainsRuntime copied to clipboard
JBR-6771 BoxLayout throws mysterious NPEs due to previous exceptions
This isn't really a bug, more like an inconvenience that masks real bugs.
The checkRequests method only does layout initialization
if it isn't initialized already. However, when an exception
is thrown during the initialization, the layout may end up
in a half-initialized state.
Fix this by using the field that is initialized the last to check if the layout is initialized. If that field is null, it may mean that the layout isn't initialized or that the last attempt failed midway. Then we try again. This attempt can, of course, break for the same reason as the previous one, but in that case we'll at least get a stack trace pointing to a real cause of the error and not some mysterious NPE that seems to be impossible from the logic.