Phixsura opened a new pull request, #22330:
URL: https://github.com/apache/kafka/pull/22330

   ## Background
   [KAFKA-14490](https://issues.apache.org/jira/browse/KAFKA-14490) proposes 
replacing checked `IOException` with `UncheckedIOException` in the log layer, 
following the pattern already adopted by the raft module. The ticket 
description specifically calls out `LazyIndex`'s private constructor as a 
candidate for simplification once `IOException` is unchecked.
   
   This is the first PR in the KAFKA-14490 series. Plan posted on the ticket 
walks through the remaining 17 files in dependency order.
   
   ## Changes
   - `LazyIndex.get` / `renameTo` / `deleteIfExists` / `close` no longer 
declare `throws IOException`. `IOException` is caught at the file-IO boundary 
inside `IndexFile`, `IndexValue` and the loader, and re-thrown as 
`UncheckedIOException`. This mirrors `FileRawSnapshotReader` / 
`FileRawSnapshotWriter` / `Snapshots` / `FileQuorumStateStore` / `KafkaRaftLog` 
in the raft module.
   - The private constructor changes from `(IndexWrapper, long, int, 
IndexType)` to `(IndexWrapper, IndexLoader<T>)`. The new `IndexLoader<T>` is a 
small `@FunctionalInterface` that allows the lambda to declare `throws 
IOException`. `forOffset` and `forTime` now pass a lambda that captures 
`baseOffset` and `maxIndexSize` directly.
   - The previous `loadIndex` private method and its 
`@SuppressWarnings("unchecked")` switch on `IndexType` are removed. The 
remaining `@SuppressWarnings("unchecked")` on `get` is for the `(IndexValue<T>) 
wrapper` cast, which is structurally required by the `<?>` wildcard on 
`instanceof IndexValue<?>` and cannot be eliminated without a larger refactor.
   
   ## Scope kept minimal
   External callers' method signatures (e.g. `LogSegment.offsetIndex() throws 
IOException`) are left untouched. Their `throws IOException` clauses become 
redundant since `LazyIndex.get` no longer throws checked, but Java permits 
over-declared `throws` and pruning them belongs in the follow-up PRs that 
convert the surrounding files. This keeps the blast radius of the first PR 
limited to `LazyIndex.java`.
   
   ## Verification
   - `:storage:compileJava` clean.
   - `:storage:test --tests "*LogSegment*" --tests "*Index*"` all green.
   - `:core:test --tests "*LogSegment*" --tests "*UnifiedLog*" --tests 
"*LazyIndex*"` all green (covers the Scala `LogTestUtils` and 
`RemoteLogManagerTest` callers).
   - `:storage:spotlessCheck`, `:storage:checkstyleMain`, 
`:storage:checkstyleTest`, `:storage:spotbugsMain --rerun-tasks` all clean.
   
   ## Committer review notes
   Happy to split out the constructor cleanup into its own PR if reviewers 
prefer the IOException conversion be reviewed in isolation first.


-- 
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]

Reply via email to