question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unneeded printStackTrace

See original GitHub issue

At https://github.com/zeromq/jeromq/blob/713a3e0f0e940497cc58b0d6dcc0f6873e35301e/src/main/java/zmq/Signaler.java#L137

We have ZMQ that print a stack trace to stderr. I don’t think a library should be allowed to directly do that. Especialy when the exception is as quite normal java.nio.channels.ClosedByInterruptException and is thrown during . a plain: zpoller.poll(-1L);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
fredoboulocommented, Apr 13, 2018

I would be more radical:

  • If the exception happens and is handled, there is no need for a stacktrace.
  • It the exception happens and is unhandled, that means some devs need to be performed to handle the situation.
  • If the exception does not happen, an assert (false) is even better as it enforces the behaviour of the dead branch of the code.

I did not see occurrences of this stacktrace (and the others of this file, but was not keen to enforce it drastically so I left these traces (several of them are in this file as well).

I agree with you: No stacktrace. If the library handles the situation.

0reactions
daveyarwoodcommented, Oct 28, 2018

I still see 56 instances of printStackTrace in the repo, 18 of which are in the library code (as opposed to in tests, where it might be more feasible to do it).

I agree with @fredoboulo about taking a more extreme approach to this. I don’t think there’s any reason why we should print stacktraces to STDERR and then continue running the program. We should handle all exceptions or let them explode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is exception.printStackTrace() considered bad practice?
It may become larger and larger and is filled with useless data because usually you have no context and no timestamp and so...
Read more >
Throwable printStackTrace() method in Java with Examples
This method prints a stack trace for this Throwable object on the standard error output stream. The first line of output shows the...
Read more >
List of Java inspections | IntelliJ IDEA Documentation - JetBrains
Call to printStackTrace() ... Unnecessary final on local variable or parameter. Disabled. Warning icon Warning. Unnecessary null check before equals() call.
Read more >
Deleting a bucket - Amazon Simple Storage Service
If you are unable to delete an Amazon S3 bucket, consider the following: Make sure the bucket is empty – You can only...
Read more >
Finding Unused Gradle Dependencies - Baeldung
Learn how to use the Gradle Nebula Lint plugin to identify and fix unused dependencies in your project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found