Uploaded image for project: 'tools.trace'
  1. TTRACE-7

clone-throwable on type java.lang.Throwable either wastes computation or is missing cond

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Labels:
      None

      Description

      The body of clone-throwable is currently:

      (extend-type java.lang.Throwable
        ThrowableRecompose
        (clone-throwable [this stack-trace args] 
          (try
            (let [ctor (.getConstructor (class this) (into-array [java.lang.String]))
                  arg (first args)]
              (string? arg)
              (doto (.newInstance ctor (into-array [arg])) (.setStackTrace stack-trace))
              :else (doto (.newInstance ctor (into-array [(str arg)])) (.setStackTrace stack-trace)))
            (catch Exception e# this))))
      

      Note that the return value of (string? arg) disappears into nowhere, as is the :else, and both doto's are always executed.

      It appears that perhaps there should be a cond wrapped around the body of the let, as there is in the clone-throwable implementation for type java.nio.charset.CoderMalfunctionError earlier in the file, or these unnecessary bits of code should be removed.

        Attachments

          Activity

            People

            • Assignee:
              lprefontaine Luc Préfontaine
              Reporter:
              jafingerhut Andy Fingerhut
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: