RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.59k stars 247 forks source link

StreamEncoder have to reset cached ClazzNameRegistry #250

Closed ykalemi closed 6 years ago

ykalemi commented 6 years ago

Maybe I should add some description.

FSTObjectOutput is stored in a threadlocal. And before every usage FSTConfiguration sets itself inside FSTEncoder (see FSTConfiguration#getOut). That's why FSTEncoder have to reset cached ClazzNameRegistry - registry depends on configuration. Registry have to be rewritten when configuration was changed.

In the test I reproduce this bug. There is two FSTConfiguration instances. Timestamp.class isn't registered in the second configuration. But ClazzNameRegistry wasn't reset and FST serialize value like class is registered.

The same code is in FSTStreamDecoder.

(BTW, FSTStreamDecoder is only one implementation of FSTDecoder, where setConf method is correct. Am I right, that FSTJsonDecoder/Encoder and FSTBytezDecoder/Encoder also need this fix?)

RuedigerMoeller commented 6 years ago

Thanx :))

RuedigerMoeller commented 6 years ago

nice beard :)