Recently, I am experiencing a very strange error which I am unable to reproduce locally. It happens on a server (CentOS) inside a Spring Boot application.
calling new Date() (java.util.Date) produces wrong time. And I am not talking about an hour difference due to different timezone. The datetime is off by X minutes. It seems that it is gradually starting to lack behind the current time.
When getting the current system clock time, it seems to be correct but the Java time is gradually increasing the difference (not by one minute every minute but slower). Almost like the JVM existed in some time bubble with different laws of time.
This issue starting happening accidentally today after a long run without any problems.
Could someone suggest what should I try to debug this issue? I am clueless and cannot replicate this issue locally (everything works on local machine).
EDIT: The server is running on a virtualized VM stack, as I just found out. I am not sure about the specific HW configuration, though.
EDIT2: I think I found the problematic part. The component causing this problem is running inside a threadpool, so I suspect that all threads in the pool are busy and the requests are queued so it takes gradually more time to handle the requests in which I am setting current timestamp.
Example:
@Async
public Date sendTimeToOtherServer() {
Date date = new Date()
// code that sends the date to different server
}