Skip to content

Move the logging of exceptions before the logging of backtraces#2110

Merged
headius merged 1 commit intojruby:masterfrom
iconara:log_exceptions_before_backtraces
Nov 5, 2014
Merged

Move the logging of exceptions before the logging of backtraces#2110
headius merged 1 commit intojruby:masterfrom
iconara:log_exceptions_before_backtraces

Conversation

@iconara
Copy link
Copy Markdown
Contributor

@iconara iconara commented Nov 5, 2014

When -Xlog.backtraces=true and -Xlog.exceptions=true are used together the backtrace is logged before the exception, which is the opposite of what you would expect, and makes the output harder to understand.

This moves the logging of exceptions to before the code that triggers the logging of the backtraces.

This is not a fantastic solution, there’s nothing in this change that makes sure that the order stays this way, as soon as someone else does a refactoring of the code this will probably become inconsistent.


Here's a flowchart of who's calling whom to print the exception and the backtraces. I made it just to see if I could find a better way of making sure the exception is printed before the backtrace, but I think it would be too dangerous if I tried, I don't know how to check for things that would break:

img_1107_small

When -Xlog.backtraces=true and -Xlog.exceptions=true are used together the backtrace is logged before the exception, which is the opposite of what you would expect, and makes the output harder to understand.

This moves the logging of exceptions to before the code that triggers the logging of the backtraces.

This is not a fantastic solution, there’s nothing in this change that makes sure that the order stays this way, as soon as someone else does a refactoring of the code this will probably become inconsistent. However, I’ve followed the code to find out how the backtraces and exceptions are logged, and this change is the only one I could come up with that wouldn’t require a much more dangerous operation.
@headius
Copy link
Copy Markdown
Member

headius commented Nov 5, 2014

This looks like an OK fix. Perhaps we can come up with a test for it? Shouldn't be hard to check that the output of a child matches proper order.

headius added a commit that referenced this pull request Nov 5, 2014
Move the logging of exceptions before the logging of backtraces
@headius headius merged commit 5ee82b6 into jruby:master Nov 5, 2014
@headius headius modified the milestones: JRuby 9000, JRuby 9.0.0.0, JRuby 9.0.0.0-pre1 Nov 5, 2014
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.

2 participants