racorn opened a new pull request #6454: Pulsar Java client: Use System.nanoTime() instead of
System.currentTimeMillis() to measure elapsed time
URL: https://github.com/apache/pulsar/pull/6454
Fixes #6453
### Motivation
`ConsumerBase` and `ProducerImpl` use `System.currentTimeMillis()` to measure the elapsed
time in the 'operations' inner classes (`ConsumerBase$OpBatchReceive` and `ProducerImpl$OpSendMsg`).
An instance variable `createdAt` is initialized with `System.currentTimeMills()`, but it
is not used for reading wall clock time, the variable is only used for computing elapsed time
(e.g. timeout for a batch).
When the variable is used to compute elapsed time, it would more sense to use `System.nanoTime()`.
### Modifications
The instance variable `createdAt` in `ConsumerBase$OpBatchReceive` and `ProducerImpl$OpSendMsg`
is initialized with `System.nanoTime()`. Usage of the variable is updated to reflect that
the variable holds nano time; computations of elapsed time takes the difference between the
current system nano time and the `createdAt` variable.
The `createdAt` field is package protected, and is currently only used in the declaring
class and outer class, limiting the chances for unwanted side effects.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
|