Add transient keyword to cached toString() value in _str

Description

_str field in Keyword and Symbol classes lazily caches result of toString(). Because this field is not transient, serializing (using Java serialization) any keyword or symbol before and after calling toString() for the first time yields different results:

This issue came up when I was trying to use keywords as key in [Hazelcast](https://github.com/hazelcast/hazelcast) map. Hazelcast uses serialized keys in various scenarios, thus if I first put something to map under key :k and then print :k, I can no longer find such key.

Approach: Add transient keyword to _str field in Keyword and Symbol classes

Patch: CLJ-1408-3.patch

Screened by: Brenton Ashworth

Environment

None

Activity

Show:
Alex Miller
August 23, 2014, 5:00 AM

Updated the patch for latest master and added the obvious test.

Andy Fingerhut
August 2, 2014, 3:29 AM

Tomasz, in addition to Alex's previous comment, it appears that a commit made to Clojure master earlier today causes your patches to no longer apply cleanly. I haven't looked to see whether updating the patches would be easy, but likely it is.

Alex Miller
June 20, 2014, 3:22 PM

On second thought, it looks like we have most of the infrastructure for serialization testing anyways, so would appreciate an updated patch with the example turned into a serialization test. Please see test/clojure/test_clojure/serialization.clj for a place to put this (using existing roundtrip function).

Tomasz Nurkiewicz
May 9, 2014, 9:55 PM

Removed `private` keyword

Alex Miller
May 9, 2014, 4:16 AM

Hi Tomasz, I noticed you added the private keyword - please remove that and update the patch.

Completed
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Unassigned

Reporter

Tomasz Nurkiewicz

Labels

Approval

Ok

Patch

Code and Test

Priority

Minor

Affects versions

Fix versions