[
https://issues.apache.org/jira/browse/FREEMARKER-119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16945401#comment-16945401
]
Alex Poruchikov commented on FREEMARKER-119:
--------------------------------------------
Hessian (Burlap) has two ways to add custom (De)Serializer.
First - via {{com.caucho.hessian.io.SerializerFactory}} instance, e.g.
{{hessianInput.getSerializerFactory().addFactory(...)}}. It is not suitable for
this case.
Second - via so called "Context (De)Serializer", see
{{com.caucho.hessian.io.ContextSerializerFactory#getCustomDeserializer(Class
c)}}, it uses reflection to instantiate deserializer class by name.
Deserializer class should be in the same package as the class that should be
deserialized, and should have name like {{MyClassHessianDeserializer}} (for
class {{MyClass}}).
This approach does not handle inheritance hierachy at all. And, because too
many descendants of {{freemarker.template.TemplateException}} exists, it is,
probably, unusable in this case too.
But, from the other hand, these deserializers may be placed in the separate jar.
See attachments for working example of such custom deserializer for
{{InvalidReferenceException}}.
[^InvalidReferenceExceptionHessianDeserializer.java]
[^TemplateExceptionDeserializerTest.java]
[^TemplateException_test2.hessian]
> TemplateException throws NPE after deserialization
> --------------------------------------------------
>
> Key: FREEMARKER-119
> URL: https://issues.apache.org/jira/browse/FREEMARKER-119
> Project: Apache Freemarker
> Issue Type: Bug
> Components: engine
> Affects Versions: 2.3.27-incubating, 2.3.29
> Reporter: Alex Poruchikov
> Priority: Major
> Attachments: InvalidReferenceExceptionHessianDeserializer.java,
> TemplateExceptionDeserializerTest.java, TemplateException_test2.hessian
>
>
> freemarker.template.TemplateException cannot be deserealized properly,
> because of transient field "lock", used in getMessage() method. See line 441
> in TemplateException.java.
> It throws NPE when getMessage() method is called on deserialized object.
> Problem appears, at least, with Hessian and Burlap serialization protocols
> from Caucho.com.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)