We're updating the issue view to help you get more done. 

clojure.test/inc-report-counter is not thread safe

Description

clojure.test/inc-report-counter function combines dereferencing the report-counters ref and operating on the previous state of the ref, leading to race conditions during concurrent use.

1 2 (dosync (commute *report-counters* assoc name (inc (or (*report-counters* name) 0))))

Approach: Rewrite update function to be entirely in terms of the old state:

1 (dosync (commute *report-counters* update-in [name] (fnil inc 0)))

Patch: fix-CLJ-1528.diff
Screened by: Alex Miller

Environment

OS X, Clojure 1.7, Macbook pro

Status

Assignee

Alexander Redington

Reporter

Alexander Redington

Labels

Approval

Ok

Patch

Code

Fix versions

Affects versions

Release 1.7

Priority

Critical