<< Back to previous view

[CLJ-1652] clojure.test counter reports are not thread safe Created: 30/Jan/15  Updated: 30/Jan/15  Resolved: 30/Jan/15

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.6
Fix Version/s: None

Type: Defect Priority: Major
Reporter: David Sargeant Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Attachments: File test-thread-safety.diff    
Patch: Code

 Description   

The update to the

*report-counters*
ref in the inc-report-counter function is not atomic and does not produce the expected number of assertions when tests are run on multiple threads.

Failure example:

(use 'clojure.test)

(deftest test-counter-parallel
  (doall (pmap (fn [x] (is true)) (range 1000))))
  
(run-tests)

Ran 1 tests containing 183 assertions.
0 failures, 0 errors.
{:type :summary, :fail 0, :error 0, :pass 183, :test 1}

Same example, but single-threaded:

(use 'clojure.test)

(deftest test-counter
  (doall (map (fn [x] (is true)) (range 1000))))
  
(run-tests)

Ran 1 tests containing 1000 assertions.
0 failures, 0 errors.
{:type :summary, :fail 0, :error 0, :pass 1000, :test 1}

The attached patch fixes the issue.



 Comments   
Comment by Alex Miller [ 30/Jan/15 12:40 PM ]

Dupe of CLJ-1528 I think.





[CLJ-1651] Erroneous error message when using into to create a map. Created: 29/Jan/15  Updated: 29/Jan/15

Status: Open
Project: Clojure
Component/s: None
Affects Version/s: Release 1.7
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Justin Glenn Smith Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: error-reporting


 Description   

If you provide a sequence instead of a vector type for the entries provided to into for creating a hash-map, the error message is misleading.

org.noisesmith.orsos=> (into {} '((:a 0) (:b 1)))

ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj (ATransientMap.java:44)

As we see, it reports the type of the first item in the entry, rather than the actual error, the type of the entry itself, which can be particularly confusing if the key in the entry is actually a valid type to be an entry:

=> (into {} '((["a" 1] ["b" 2]) (["c" 3] ["d" 4])))

ClassCastException clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj (ATransientMap.java:44)






[CLJ-1650] compile forces namespace reloading from AOT classfile Created: 29/Jan/15  Updated: 30/Jan/15

Status: Open
Project: Clojure
Component/s: None
Affects Version/s: Release 1.7
Fix Version/s: Release 1.7

Type: Defect Priority: Major
Reporter: Nicola Mometto Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: regression

Attachments: Text File 0001-CLJ-1650-compile-forces-namespace-reloading-from-AOT.patch    
Patch: Code
Approval: Vetted

 Description   

The patch for CLJ-979 exposed an issue with how clojure.core/compile is implemented, which causes the bug reported here: https://groups.google.com/d/msg/clojure-dev/jj87-4yVlWI/YKG4QazhPuAJ

The cause of this regression is that clojure.core/compile doesn't take into account clojure.core/loaded-libs, causing

(binding [*compile-files* true] (require 'some.ns))
(compile 'some.ns)

to reload 'some-ns from the AOT class with the call to compile.

Since the AOT compiled namespace is not loaded by DynamicClassLoader but using the underlying java.net.URLClassLoader, code that relies on deftypes will have references to the AOT versions hardcoded, breaking the class loading policy introduced with CLJ-979 of prefering the in-memory versions to the AOT ones.

The fix for this, as implemented in the attached patch, is to make compile loaded-libs-aware, so that it won't force any namespace re-loading when unnecessary.






Generated at Fri Jan 30 15:45:20 CST 2015 using JIRA 4.4#649-r158309.