Object property change is not saved after streaming in java

后端 未结 1 1844
北荒
北荒 2020-12-11 09:57

Update: OK so I\'ve grayed out parts of code and found what was causing the problem. I\'ve added here 3 lines of code with the comment \"this is the added code that causes t

相关标签:
1条回答
  • 2020-12-11 10:31

    When you output an object using writeObject(Object), the instance will be serialized (as expected). The problem is, the serialized version will be cached, and any time you attempt to write that same instance a second time, the cached version of the serialized instance is referenced.

    To avoid this, you can either call reset() after calling writeObject(Object), or you could use writeUnshared(Object)

    0 讨论(0)
提交回复
热议问题