chia7712 commented on code in PR #15488:
URL: https://github.com/apache/kafka/pull/15488#discussion_r1518649558


##########
core/src/test/scala/unit/kafka/log/LogLoaderTest.scala:
##########
@@ -352,19 +352,15 @@ class LogLoaderTest {
       // Intercept all segment read calls
       val interceptedLogSegments = new LogSegments(topicPartition) {
         override def add(segment: LogSegment): LogSegment = {
-          val wrapper = new LogSegment(segment) {
-
-            override def read(startOffset: Long, maxSize: Int, maxPosition: 
Long, minOneMessage: Boolean): FetchDataInfo = {
-              segmentsWithReads += this
-              super.read(startOffset, maxSize, maxPosition, minOneMessage)
-            }
-
-            override def recover(producerStateManager: ProducerStateManager,
-                                 leaderEpochCache: 
Optional[LeaderEpochFileCache]): Int = {
-              recoveredSegments += this
-              super.recover(producerStateManager, leaderEpochCache)
-            }
-          }
+          val wrapper = Mockito.spy(segment)

Review Comment:
   > What is the purpose of this change?
   
   It seems to me there are two reason of removing the copy constructor.
   
   1. it does not copy all fields of `LogLoader`, so it is potential bug if we 
use it in the production (in the future)
   2. the copy constructor is used only in testing, so it should be fine to 
move the related behavior to testing code
   
   > Using a spy mock instead of a copy constructor is not better. 
   
   pardon me, could you please share the reason to me?



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to