-
Notifications
You must be signed in to change notification settings - Fork 359
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
ThreadCtx.cleanup(): when to call? #94
Comments
Maybe PdfBoxRenderer should just be an AutoCloseable, so you can use try-with-resources? |
Thanks @rototor |
@danfickle AutoCloseable is only available with JDK 1.7+, but Closeable exists since JDK 1.5. If PdfBoxRenderer would extend Closeable and use close() for the cleanup it would be AutoCloseable with JDK 1.7+, because Closeable extends AutoCloseable with JDK 1.7+. |
- Remove deprecated methods. - Make sure the PDDocument is closed in a finally block. - Make an explicit method createPDFWithoutClosing for those who need to post-process. - Implement Closeable interface so that it can be used with try with resources. - Mark unused and untested methods as deprecated. Thanks @rototor @dtrucken @schmitch
Implemented |
I got a Tomcat warning because the ThreadLocal of ThreadCtx where not destroyed when my webapp unloaded. To silence this warning (and remove the potential memory leak) I call
ThreadCtx.cleanup();
in my code after I generated the PDF.Should
PdfBoxRenderer.cleanup()
also remove the ThreadLocal? And should we document this somewhere, i.e. that you should callPdfBoxRenderer.cleanup()
- at least in a web application?The text was updated successfully, but these errors were encountered: