Bug in File.getLastModified()
Ricardo Almeida
ric.almeida at gmail.com
Fri Mar 31 08:35:59 UTC 2017
Just to add another though...
I was just double-reading the documentation and it says:
"All platforms support file-modification times to the nearest second,
but some provide more precision. The argument will be truncated to fit
the supported precision."
So, if the platform supports it, the argument is NOT truncated... Next we have:
"the next invocation of the lastModified() method will return the
(possibly truncated) time argument that was passed to this method"
The way I read this sentence, it is 100% related with the first
sentence. It should return the value that was applied... if the system
supports only second precision, it is truncated. Otherwise, it should
return the not truncated value.
Thanks,
Ricardo Almeida
On 31 March 2017 at 09:28, Ricardo Almeida <ric.almeida at gmail.com> wrote:
> Hi all,
>
> I agree with Sean, as said in the bug. The reason we have in the
> documentation that it can be possibly truncated is most likely related
> to older linux's that wouldn't support it... If the data is there and
> available, why explicitly truncate it?
>
> Also note that the workaround also doesn't work in Ubuntu with Oracle JDK 8u121.
>
> Regarding causing subtle bugs, I believe current behavior can cause
> more issues... As that was the reason why I open this bug. Everything
> was working fine in the most developers machines (windows) and bugs
> occurred in production (linux with oracle jdk)...
>
> Thanks,
> Ricardo Almeida
>
>
> On 31 March 2017 at 01:49, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
>> As noted in [1], it looks like the specification [2] already dealt with the
>> situation via the "possibly truncated" phrase:
>>
>> "If the operation succeeds and no intervening operations on the file take
>> place, then the next invocation of the lastModified() method will return the
>> (possibly truncated) time argument that was passed to this method.”
>>
>> Given the existence of a workaround and the possibility of causing subtle
>> bugs (as noted by Stuart in the issue comments [1]), I would be inclined to
>> resolve this as Not an Issue.
>>
>> Thanks,
>>
>> Brian
>>
>> On Mar 30, 2017, at 5:47 AM, Seán Coffey <sean.coffey at oracle.com> wrote:
>>
>> I see that JDK-8177809 [1] has been logged.
>>
>> […]
>>
>> [1] https://bugs.openjdk.java.net/browse/JDK-8177809
>>
>>
>> [2]
>> http://download.java.net/java/jdk9/docs/api/java/io/File.html#setLastModified-long-
More information about the core-libs-dev
mailing list