4 Replies Latest reply on Aug 22, 2019 10:55 AM by Ondrej Chaloupka

    An approach to substitute e.printStackTrace() for exception traces being printed with the logger

    Ondrej Chaloupka Master

      There was recently a discussion at a pull request about leaving or not leaving e.printStackTrace() calls in the code.

      JBTM-3178 Add warning for AbstractRecord create failure by mmusgrov · Pull Request #1486 · jbosstm/narayana · GitHub

       

      From my perspective use of the calls of Exception.printStackTrace() should be avoided and if possible the code should be cleaned up from parts where bad practices are used. This is one of them (Best Practices | PMD Source Code Analyzer ).

      For me the only valid reason to talk about leaving a bad practice code is because of the backward compatibility. Which I personally do not consider being the case here. It's hard for me to imagine a developer depending on a specific exception trace to be thrown to stderr.

       

      To reference the Tom's opinion on this from the issue is here: JBTM-3178 Add warning for AbstractRecord create failure by mmusgrov · Pull Request #1486 · jbosstm/narayana · GitHub

      Where he says that

      • we have to consider whether making the change outweighs the benefit of users who may be relying on the old behaviour

       

      I'm interested to find and understand what are the possible issues with changing the printStackTrace() for the logger, are there some?

       

      Thank you

      Ondra