SwitchEV / RISE-V2G

The only fully-featured reference implementation of the Vehicle-2-Grid communication interface ISO 15118
MIT License
219 stars 92 forks source link

Time measurements based on system time #7

Closed lategoodbye closed 7 years ago

lategoodbye commented 7 years ago

Rise V2G uses System.currentTimeMillis() to measure timings, which based on the current system time. This could leads to hard reproducible runtime issues, because e.g. NTP could change the system time and influence the result of System.currentTimeMillis().

In order to avoid this always use System.nanoTime() for time measuring, which is recommend by Oracle for this use case.

MarcMueltin commented 7 years ago

I see what you mean. This is a corner case since the NTP would need to change within the first 20s of a communication setup because that's where System.currentTimeMillis() is used. But it's a good catch and I will change it with the next release.

MarcMueltin commented 7 years ago

Issue resolved with commit f301e82