data.fressian

Roundtrip encoding of values are unequal under Clojure 1.6

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure 1.6

Description

While running the tests on https://github.com/danielcompton/data.fressian-test I found this bug:

(let [mys {[3] [] :a nil, :b nil :c nil :d nil :e nil :f nil :g nil}
      myf (fr/read (fr/write mys))]
  (println (type mys))
  (println (type (key (first mys))))
  (println (type myf))
  (println (type (key (first myf))))
  (= mys myf))
clojure.lang.PersistentArrayMap
clojure.lang.PersistentVector
clojure.lang.PersistentHashMap
java.util.Arrays$ArrayList
=> false

Changing the key [3] to :x

{:x [] :a nil, :b nil :c nil :d nil :e nil :f nil :g nil}

or removing another kv pair

{[3] [] :b nil :c nil :d nil :e nil :f nil :g nil}

will make the roundtrip encoding of Fressian values equal.

This is because of the changes in hashing behaviour introduced in 1.6 and relates to CLJ-1372. I think there may also be some interaction with Fressian's creation of ArrayMaps for maps with less than 8 kv pairs.

One fix would be to make sure data.fressian always returns persistent Clojure data structures, so it avoids tripping over Clojure no longer having Java data structures be equal to their analogous Clojure ones.

Activity

Hide
Daniel Compton added a comment -

Clarify issue.

Show
Daniel Compton added a comment - Clarify issue.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: