You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/06/08 08:31:43 UTC

[GitHub] [kafka] divijvaidya commented on a diff in pull request #13823: MINOR: Move MockTime to server-common

divijvaidya commented on code in PR #13823:
URL: https://github.com/apache/kafka/pull/13823#discussion_r1222638839


##########
server-common/src/test/java/org/apache/kafka/server/util/MockTime.java:
##########
@@ -27,15 +23,21 @@
  * 1. This has an associated scheduler instance for managing background tasks in a deterministic way.
  * 2. This doesn't support the `auto-tick` functionality as it interacts badly with the current implementation of `MockScheduler`.
  */
-class MockTime(currentTimeMs: Long, currentHiResTimeNs: Long) extends JMockTime(0, currentTimeMs, currentHiResTimeNs) {
-
-  def this() = this(System.currentTimeMillis(), System.nanoTime())
+public class MockTime extends org.apache.kafka.common.utils.MockTime {
+    public final MockScheduler scheduler;
 
-  val scheduler = new MockScheduler(this)
+    public MockTime() {
+        this(System.currentTimeMillis(), System.nanoTime());

Review Comment:
   please consider using `Time.SYSTEM`



##########
server-common/src/test/java/org/apache/kafka/server/util/MockTime.java:
##########
@@ -27,15 +23,21 @@
  * 1. This has an associated scheduler instance for managing background tasks in a deterministic way.
  * 2. This doesn't support the `auto-tick` functionality as it interacts badly with the current implementation of `MockScheduler`.
  */
-class MockTime(currentTimeMs: Long, currentHiResTimeNs: Long) extends JMockTime(0, currentTimeMs, currentHiResTimeNs) {
-
-  def this() = this(System.currentTimeMillis(), System.nanoTime())
+public class MockTime extends org.apache.kafka.common.utils.MockTime {

Review Comment:
   My preference would be to rename this class. Having two MockTime is super confusing. 



##########
server-common/src/test/java/org/apache/kafka/server/util/MockTime.java:
##########
@@ -27,15 +23,21 @@
  * 1. This has an associated scheduler instance for managing background tasks in a deterministic way.
  * 2. This doesn't support the `auto-tick` functionality as it interacts badly with the current implementation of `MockScheduler`.
  */
-class MockTime(currentTimeMs: Long, currentHiResTimeNs: Long) extends JMockTime(0, currentTimeMs, currentHiResTimeNs) {
-
-  def this() = this(System.currentTimeMillis(), System.nanoTime())
+public class MockTime extends org.apache.kafka.common.utils.MockTime {

Review Comment:
   should this implement AutoCloseable so that we can shutdown the scheduler correctly?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org