-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
AnnotatedMethod.getValue()/setValue()
doesn't have useful exception message
#2509
Comments
Makes sense. Change itself would be easy to make of course, but I think what would be great is a unit test to verify that message from original exception message is retained. |
@cowtowncoder I'm looking for easy Hacktoberfest issues and may try to take this on - I don't see a specific test suite for AnnotatedMethod - should a new file be created? |
@dm20 You could add tests for |
Ok, so... could be under LMK if this does not make sense or you think you are missing something. Also -- yes, Hacktoberfest is a good reason! |
@cowtowncoder I think I get the gist of what you want, thx for the clarification! I will open a PR shortly. |
Cool! |
I'm having some issues running tests, I'm using Intellij - the project is all set up for the most part (it appears I did not have to add any modules or mark directories manually?) but com.fasterxml.jackson.databind.cfg.PackageVersion is not found. do I need to generate this dependency with a script or something? |
ah. Do Also: can do either against |
oh ok that makes sense - I had just tried |
perhaps I am lacking the context necessary to write useful tests, but it appears that adding public class DeserializationErrorHandlingTest extends BaseTest {
static class Bean {
public String a = "a";
public String b = "b";
public Bean() { }
public String getA() {
return this.a;
}
}
public void testGetValue() throws Exception {
AnnotatedMethod m = new AnnotatedMethod(null, Bean.class.getMethod("getA"), null, null);
Bean b = new Bean();
m.getValue(b); //throws NPE when getCause() is used in AnnotatedMethod, throws normally as is
}
} |
Maybe above example is incomplete, but it does not have exception triggered from within |
@dm20 Looking at this I think it's... somewhat more complicated. @henryptung At this point actual unit test to reproduce the issue would be useful, we have some trouble reproducing issue as reported -- I can see exception message of the original exception correctly. |
@dm20 I think this is probably not as easy as I thought -- will remove tag. You can continue if you want, but I am not assuming you will work on this one. |
@cowtowncoder ok, if I have time in the next few days I will continue to work on it. I did make a test case, but am not seeing any change in functionality on thrown exceptions when |
@dm20 Sounds good. All I need is something to actually trigger this behavior: number of distinct code paths is big and ones I tried do not actually trigger this handling. But without test I can not verify that fix is working as expected, nor guard against possible regression in future. |
No reproduciton at this point, unfortunately, will close. May be reopened with some kind of reproduction (unit test). |
Filed a PR that should resolve this issue: #3109. |
AnnotatedMethod.getValue()/setValue()
doesn't have useful exception message
@Stephan202 Excellent! Thank you for resolving this; I backported the fix in 2.13 for 2.13.0 release. |
https://github.com/FasterXML/jackson-databind/blob/d42d345/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedMethod.java#L161
InvocationTargetException.getMessage()
will always be null. Should probably be usingInvocationTargetException.getCause().getMessage()
instead.The text was updated successfully, but these errors were encountered: