-
Notifications
You must be signed in to change notification settings - Fork 1.9k
recoverStackTrace breaks exception message #1631
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
Comments
I am not sure we can do better automatically without reflectively hacking Throwable class (that probably will produce a shameful warning on Java 9+), I'll try to figure it out. To understand why it happens, I recommend you to get familiar with stacktrace recovery machinery: The main idea is to reflectively create a copy of the exception, preserving as much information from the original exception as possible. Usually, it is a message and a cause, so we reflectively call a constructor with As a workaround, you can fix this problem by extending |
Having the same issue here. I can set property |
@monosoul do you mean broken exception message or stacktrace recovery in general? I don't think we can provide something besides system property, because stacktrace recovery was designed as static property in the first place. Otherwise, everyone |
@qwwdfsad yeah, I mean broken exception message. Maybe it'd be a better idea to create a I mean, of course it's also possible to implement |
Creating One of the possible options is to prefer constructor without a message and to hack message reflectively, but again, it will require reflective access to |
@qwwdfsad Oh, yeah, you're right. I guess another solution could be to use CGLIB (or something like that) to create a proxy for the exception class. Of course it'd have a performance impact, but on the other hand this impact would only affect tests/local runs, which is fine IMO. Anyway, in our case we're just wrapping different exceptions, so we decided to just go with a static exception message and different causes. |
The easiest option is to introspect constructor parameter name using reflection and copy an exception only if the parameter is named "message". |
…(cause)' constructor. And restore the original behaviour. After #1631 this constructor's recovery mechanism was broken because 'Throwable(cause)' changes the message to be equal to 'cause.toString()' which isn't equal to the original message. Also, make reflective constructor choice independable from source-code order Fixes #3714
#3731) * Properly recover exceptions when they are constructed from 'Throwable(cause)' constructor. And restore the original behaviour. After #1631 this constructor's recovery mechanism was broken because 'Throwable(cause)' changes the message to be equal to 'cause.toString()', which isn't equal to the original message. Also, make reflective constructor choice undependable from source-code order Fixes #3714
Consider the following test case:
It is failing on message assertion:
It looks like
recoverStackTrace / tryCopyException
incorrectly recovers the exception. #1040 mentions that similar problem is fixed in 1.2.0, but this test fails on 1.3.2.The text was updated successfully, but these errors were encountered: