RFR: 7902698: Collision of zero timestamp as a special value with use in filesystems
Dmitry Bessonov
dbessono at openjdk.java.net
Tue Jan 25 20:31:40 UTC 2022
On Thu, 20 Jan 2022 03:27:00 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
> This fixes a bug when the timestamp of a test file is set to zero, since jtharness currently uses zero as a special value. See discussion in [CODETOOLS-7902698](https://bugs.openjdk.java.net/browse/CODETOOLS-7902698).
It seems that previously zero default value served as "undefined yet" for these fields, now switched to "-1" as their default value. However 'URLConnection::getLastModified' returns "0 if not known" and 'File::lastModified' spec asserts: "returns 0L if the file does not exist or if an I/O error occurs. The value may be negative indicating the number of milliseconds before the epoch".
It possibly would be more reliable and readable to switch types of these fields from 'long' to OptionalLong with OptionalLong.empty() as their default value.
-------------
PR: https://git.openjdk.java.net/jtharness/pull/22
More information about the jtharness-dev
mailing list