Skip to content
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

Avoiding printStackTrace() #251

Closed
harbulot opened this issue Jul 13, 2018 · 1 comment
Closed

Avoiding printStackTrace() #251

harbulot opened this issue Jul 13, 2018 · 1 comment

Comments

@harbulot
Copy link
Contributor

I've noticed the same issue as described in #224. The PDF I'm generating works, but there's a fairly long stack trace that is visible on the standard error every time I generate this PDF.

The exception that causes this stack trace is effectively invisible and ignored by the calling application, while the printStackTrace() statement just displays it on the standard error. It makes perfect sense to have these statements for quick development, but once this library is used in an application, they just put more noise in the standard error logs (if captured), and are completely separate from that application's logging system.

Perhaps they should either be removed altogether (to make those exceptions fail silently) or, better, use a logging framework (e.g. com.openhtmltopdf.util.XRLog) to log them with debug or warning levels.

There seems to be about 20 or so occurrences like these:

obsolete-archive/examples/nomaven/misc/src/main/java/Review.java:119:            e.printStackTrace();
obsolete-archive/src/experimental/java/org/xhtmlrenderer/experimental/WorkQueue.java:68:                                e.printStackTrace();
obsolete-archive/src/experimental/java/org/xhtmlrenderer/experimental/WorkQueue.java:74:                e.printStackTrace();  // FIXME
openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/AbstractOutputDevice.java:195:                ex.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/resource/FSEntityResolver.java:88:                e.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/swing/DOMInspector.java:284:            ex.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Configuration.java:160:        e.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Configuration.java:231:        th.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Configuration.java:719:            ex.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/GenerateBigFile.java:35:            e.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Util.java:368:        e.printStackTrace(pw);
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Util.java:382:        e.printStackTrace(pw);
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Uu.java:124:            ex.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/XRLog.java:238:            ex.printStackTrace();
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/XRSimpleLogFormatter.java:65:            th.printStackTrace( new PrintWriter( sw ) );
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/Zipper.java:53:            e.printStackTrace();
openhtmltopdf-examples/src/main/java/com/openhtmltopdf/visualtest/VisualTester.java:82:                 e.printStackTrace();
openhtmltopdf-examples/src/main/java/com/openhtmltopdf/visualtest/VisualTester.java:108:                        th.printStackTrace(new PrintWriter(sw, true));
openhtmltopdf-objects/src/main/java/com/openhtmltopdf/objects/pdf/MergeBackgroundPdfDrawer.java:98:                     e1.printStackTrace();
openhtmltopdf-objects/src/main/java/com/openhtmltopdf/objects/pdf/MergeBackgroundPdfDrawer.java:100:                    e1.printStackTrace();
openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxFontResolver.java:88:                                      e.printStackTrace();
openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxFontResolver.java:99:                              e.printStackTrace();
openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/OpenHtmlGvtFont.java:53:                   e.printStackTrace();
danfickle added a commit that referenced this issue Jul 14, 2018
…ith our close font workaround. [ci skip]

This really needs a release of PDFBOX 2.0.12 for a proper fix.
@danfickle
Copy link
Owner

As requested, removed stack trace printing. I'll close this issue in favor of #224.

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

No branches or pull requests

2 participants