tools.trace

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

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • 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.

Activity

Hide
Luc Préfontaine added a comment -

Yep, missing cond. Fixed.

Show
Luc Préfontaine added a comment - Yep, missing cond. Fixed.
Hide
Luc Préfontaine added a comment -

Missing cond added

Show
Luc Préfontaine added a comment - Missing cond added
Hide
Luc Préfontaine added a comment -

Official release 0.7.8, bad readme in 0.7.7

Show
Luc Préfontaine added a comment - Official release 0.7.8, bad readme in 0.7.7

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: