kowshik opened a new pull request #10426: URL: https://github.com/apache/kafka/pull/10426
**Problems:** Before refactoring the recovery logic ([KAFKA-12553](https://issues.apache.org/jira/browse/KAFKA-12553)), we would like to [move the logic to initialize](https://github.com/apache/kafka/blob/d9bb2ef596343da9402bff4903b129cff1f7c22b/core/src/main/scala/kafka/log/Log.scala#L579) `LeaderEpochFileCache` out of the `Log` class and into a separate static function. In the future, once we successfully initialize `LeaderEpochFileCache` outside `Log`, we will be able pass it as a dependency into both the `Log` class constructor and the `Log` recovery module. However, currently the `LeaderEpochFileCache` constructor takes a [dependency](https://github.com/apache/kafka/blob/d9bb2ef596343da9402bff4903b129cff1f7c22b/core/src/main/scala/kafka/server/epoch/LeaderEpochFileCache.scala#L42) on `logEndOffset` (via a callback), which poses the following problems: 1. Prevents the instantiation of `LeaderEpochFileCache` outside `Log` class. Because, outside `Log` the `logEndOffset` is unavailable to be passed into `LeaderEpochFileCache` constructor. This situation blocks the recovery logic ([KAFKA-12553](https://issues.apache.org/jira/browse/KAFKA-12553)) refactor work. 2. It turns out the `logEndOffset` dependency is used only in 1 of the `LeaderEpochFileCache` methods: `LeaderEpochFileCache.endOffsetFor`, and just for 1 particular case. Therefore, it is overkill to pass it in the constructor as a dependency. Also a callback is generally not a neat way to access dependencies and it poses code readability problems too. **Solution:** This PR modifies the code such that we only pass the `logEndOffset` as a parameter into `LeaderEpochFileCache.endOffsetFor` whenever the method is called, thus eliminating the constructor dependency. This will also unblock the recovery logic ([KAFKA-12553](https://issues.apache.org/jira/browse/KAFKA-12553)) refactor work. **Tests:** I have modified the existing tests to suit the above refactor. -- 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: us...@infra.apache.org