Search code examples
dateserializationpersistencedeserializationoracle-coherence

POF Serialization/Deserialization malfuncions with Date?


I'm building a persistence tester to test if the data I'm trying to persist is correct the process is something like this:

  • Store data in variable var1;
  • Persist data in variable var1 to a coherence cache;
  • Read the data stored in cache and store it in variable var2;
  • Compare var1 with var2 and check if the values match;

The test may or may not be correct. I've been fixing some bugs but the persisted data is always the same in both var1 and var2.

The values have always matched despite of the type (Integer, Long, Double, Boolean, Class, Object, etc...). However, when persisting and reading a Date, the value in milliseconds is different. The comparison works fine, it's not the problem.

Is there any bug regarding the serialization/deserialization/persistence of Date objects? I hope you can help me.

Thanks


Solution

    1. Are you using Java serialization, Externaliable, ExternalizableLite, POF, or some custom serialization? (Assuming POF from the question title.)

    2. Could you please post a reproducer and any custom serialization code (e.g. readExternal and writeExternal methods) that you are using?

    3. Are you using a PofWriter to write the java.util.Date object out using the writeDateTime() method? Are you using a PofReader to read in the value using the readDate() method?

    4. When you say that "the value in milliseconds is different", could you please define how the values differ? What was the milliseconds before you wrote it out? What was the milliseconds that was read back in?

    5. It is also theoretically possible that something is occurring with respect to time zones. I'm curious if the time is off by exactly 15 minutes, 30 minutes, or 60 minutes, for example.