Carrot2

SimpleXML's before serialization hook (@Persist) can cause side-effects for thread-shared objects.

Details

  • Type: Refactoring Refactoring
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 3.0.1, 3.1.0, 3.1.1, 3.2.0, 3.3.0
  • Fix Version/s: 3.4.0
  • Component/s: Framework Core
  • Labels:
    None

Description

If a given serializable object has a method marked with @Persist and this method modifies the state of the object internally, calling serialization from multiple threads can cause undesired and unpredictable side effects. In particular, our AttributeDescriptor object is an example of this.

The best solution is to make serializable objects immutable and create their internal representation eagerly in the constructor instead of lazily using @Persist.

Issue Links

Activity

Hide
Dawid Weiss added a comment -

I mark this as fixed, even though the PROPER way to fix this would be to either make serializable objects immutable OR write a wrapper for Persister which would disallow serialization of the same object in two concurrent threads (this is actually simple to write, but aesthetically nasty .

Show
Dawid Weiss added a comment - I mark this as fixed, even though the PROPER way to fix this would be to either make serializable objects immutable OR write a wrapper for Persister which would disallow serialization of the same object in two concurrent threads (this is actually simple to write, but aesthetically nasty .

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: