Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make org.thymeleaf.Template serializable #378
Since org.thymeleaf.Template is cached, I think it should implement Serializable.
I think making this should should be pretty easy - perhaps it could be done for Thymeleaf 3?
Besides implementing the interface in org.thymeleaf.Template, it would also have to be added to these classes:
Also, the fields:
should be removed and looked up on demand so that when those classes are serialized, the resourceResolver and processors aren't serialized too (since they don't change, and they're not serializable, they should not be serialized).
For folks that run into problems when using Ehcache ARC (Automatic Resource Allocation) due to this issue, I've written up how to work around it at http://candrews.integralblue.com/2015/07/issues-using-ehcache-with-arc-as-the-thymeleaf-cache/
I agree that once Templates are cacheable (in Thymeleaf 3.0 we would be talking about implementations of the
Unfortunately, this is not possible with Thymeleaf 3.0's architecture and model implementations. For example (but not only), template engine events (implementations of
This kind of references cannot be easily converted into transient and re-initialized after deserialization because there might be more than one
So I'm closing this as declined, given I see no clear way of implementing this with the current or near-future engine architecture.