-
-
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
(2.8) ObjectMapper._readMapAndClose() swallows IOException on close() #629
Comments
The problem here is that in many cases this would end up hiding the real exception. That is, when closing parser as a result of an exception, not catching one from close would basically hide the real root cause, and lead to (more) difficult to debug failures. If this can be avoided this exception can (and should) pass through; but I think I wasn't able to find a clean to achieve this. If you can figure out a better way to do this, I am definitely open to improvements. |
@cowtowncoder This is handled automatically by https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#addSuppressed-java.lang.Throwable- I hope you require at least Java7 for Jackson (since Java6 is EOLed). |
No. Jackson is at low enough level that 2.4 was the first version to have baseline of Java6 (earlier Java5 was the baseline), and for core components that won't change for 2.5. Just because Oracle has EOL'd support does not mean that there weren't many installations that still run on Java6. So this is good to know for Java7; I wasn't aware of this facility. Thank you for the link. I will leave this issue open, then. Also... while I am not big fan of using Reflection for regular code, this is one place where could consider dynamically discovering |
@cowtowncoder QueryDSL implemented this very nicely on a bug I recently reported. Check out the bug description here: querydsl/querydsl#1007 (comment) and their implementation here: querydsl/querydsl#1008 Because they use a static block, selection happens once. There is no performance overhead for subsequent calls. |
Oh, by the way... you don't need to invoke |
Since Jackson 2.7 allows use of Java 7 types (although has to be dynamic wrt runtime), and 2.8 will allow regular use of language features, I think this can finally be done in 2.8. Will edit title to reflect that. |
Fixed via #1221, for 2.8.0. |
ObjectMapper._readMapAndClose()
contains this code:Does it really make sense to do this? I know that exceptions are unlikely to be thrown when closing a file that was only read file (there is no data to flush on
close()
) but the method already declares it throwsIOException
so what's the harm of letting the exception bubble up?The text was updated successfully, but these errors were encountered: