Uploaded image for project: 'OpenDJ'
  1. OpenDJ
  2. OPENDJ-6710

Use a single method for generating log error messages and stack traces if needed



      Motivation: OPENDJ-6528 and OPENDJ-6505.

      We could do with rationalizing some of our exception logging. At the moment we have many methods that output different varieties of exception message:

      • com.forgerock.opendj.util.StaticUtils#getExceptionMessage - this is the method used for the CME in this bug. It does not include any stack trace when the main exception has a message
      • com.forgerock.opendj.util.StaticUtils#stackTraceToSingleLineString(java.lang.StringBuilder, java.lang.Throwable, boolean)
      • com.forgerock.opendj.util.StaticUtils#stackTraceToSingleLineString(java.lang.Throwable, boolean) - delegates to method above
      • org.opends.server.util.StaticUtils#getBacktrace
      • org.opends.server.util.StaticUtils#getExceptionMessage - does some stuff then delegates to SDK equivalent
      • org.opends.server.util.StaticUtils#stackTraceToSingleLineString - delegates to SDK
      • org.opends.server.util.StaticUtils#stackTraceToString(java.lang.Throwable) - no delegation

      I wonder if we could replace all these with a single method that combines getExceptionMessage(), which handles recognized exception types, then fall through to stackTraceToSingleLineString() with full stack always set to true for unrecognized exceptions.

      Additional input from Jean-Noël Rouvignac: I see a lot of code calling e.getMessage() or e.getLocalizedMessage() (Java exceptions) or e.getMessageObject() (OpenDJ exceptions). I would ban them all in favour of a single call to StaticUtils.getExceptionMessage(e) which does the right thing (TM).


          Issue Links



              • Assignee:
                nicolas.capponi@forgerock.com Nicolas Capponi
                matthew Matthew Swift
                Dev Assignee:
                Nicolas Capponi
              • Votes:
                0 Vote for this issue
                3 Start watching this issue


                • Created: