chia7712 commented on code in PR #16242:
URL: https://github.com/apache/kafka/pull/16242#discussion_r1632034986
##########
clients/src/main/java/org/apache/kafka/common/utils/Time.java:
##########
@@ -30,8 +30,6 @@
*/
public interface Time {
- Time SYSTEM = new SystemTime();
Review Comment:
If we want to make sure "only one" `SystemTime` is created, maybe we can
inline the implementation? Keeping the `Time#SYSTEM` can avoid large changes.
For example:
```java
Time SYSTEM = new Time() {
@Override
public long milliseconds() {
return System.currentTimeMillis();
}
@Override
public long nanoseconds() {
return System.nanoTime();
}
@Override
public void sleep(long ms) {
Utils.sleep(ms);
}
@Override
public void waitObject(Object obj, Supplier<Boolean> condition, long
deadlineMs) throws InterruptedException {
synchronized (obj) {
while (true) {
if (condition.get())
return;
long currentTimeMs = milliseconds();
if (currentTimeMs >= deadlineMs)
throw new
org.apache.kafka.common.errors.TimeoutException("Condition not satisfied before
deadline");
obj.wait(deadlineMs - currentTimeMs);
}
}
}
};
```
WDYT?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]