Github user d2r commented on a diff in the pull request: https://github.com/apache/storm/pull/838#discussion_r45504914 --- Diff: storm-core/src/clj/backtype/storm/util.clj --- @@ -1062,6 +1062,22 @@ (defn hashmap-to-persistent [^HashMap m] (zipmap (.keySet m) (.values m))) +(defn retry-on-exception + "Retries specific function on exception based on retries count" + [tries task-description f & args] + (let [res (try {:value (apply f args)} + (catch Exception e + (if (= 0 tries) + (throw e) + {:exception e})))] + (if (:exception res) + (do + (log-error (:exception res) (str "Failed to " task-description ". Will make [" tries "] more attempts.")) + (recur (dec tries) task-description f args)) + (do + (log-debug (str "Successful " task-description ".")) + (:value res))))) --- End diff -- Let's name the var `retries` instead of `tries`, since it calls the function `tries + 1` times.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---