FlashMap's cannot be easily serialized by means other than java serialization [SPR-12757] #17354
Currently it is not easy to serialize a org.springframework.web.servlet.FlashMap using anything other than regular java serialization or frameworks that use reflective field access
The problem is that the expirationStartTime and timeToLive fields can only be set by invoking startExpirationPeriod.
So suppose that I wanted to serialize this object to a json object to store in a cookie then i would not be able to do this
Using java serialization in this context would be ill advised as this post points out
Referenced from: commits 83ff0ad
Rossen Stoyanchev commented
To provide getters and setters would compromise the design too much. Perhaps we could provide a method to return a SerializableFlashMap type with proper getters and setters and also a reverse method for creating a FlashMap from a SerializableFlashMap. Or did you have something else in mind?
Jelmer Kuperus commented
That does immediately strike me as the most elegant solution one of the problems i think is, that for some reason it stores what is effectively an expiry date as two fields and then does calculations on every request to arrive at this date. Doing the calculation once in startExpirationPeriod and then exposing a getter for this field plus a static factory method for creating a FlashMap with this value would not compromise design that much i think