Opened 8 years ago
Closed 8 years ago
#2024 closed defect (fixed)
Date and timestamp annotations may be updated even if they have not changed
Reported by: | Nicklas Nordborg | Owned by: | everyone |
---|---|---|---|
Priority: | major | Milestone: | BASE 3.9.1 |
Component: | core | Version: | |
Keywords: | Cc: |
Description
Ticket #2001 changed the behavior of core API to not register an annotation as updated if there was no change to the value.
There seems to be a bug when used with date and timestamp annotations that is triggered when calling the Annotation.setValueIfDifferent()
method from a plug-in or extensions. The web client is not affected since it has other checks to see if something has changed.
Initial debugging reveals that dates and timestamps are represented by different classes. The unmodified "new" value is using a java.util.Date
instance but the current values are using java.sql.Date
or java.sql.Timestamp
.
When comparing the new and current values we get the result that they are not equal.
It actually seems like the equals()
implementation is flawed:
Date d = ... Timestamp t = ... d.equals(t); // Return TRUE t.equals(d); // Return FALSE
For more information see: http://stackoverflow.com/questions/8929242/compare-date-object-with-a-timestamp-in-java
(In [7183]) Fixes #2024: Date and timestamp annotations may be updated even if they have not changed
The
AnnotationBatcher
had the same issue. The equals() checking could probably have been implemented in a more elegant way by usingComparator
implementations and modifying some of the utility methods. Some other time...