[
https://issues.apache.org/jira/browse/KAFKA-14490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18082137#comment-18082137
]
Canxuan Wang commented on KAFKA-14490:
--------------------------------------
I'd like to take this on. I have measured the current scope on trunk: 209
occurrences of {{throws IOException}} / {{throw new IOException}} across 18
files under
{{{}storage/src/main/java/org/apache/kafka/storage/internals/log/{}}}, against
only 2 existing usages of {{UncheckedIOException}} in the same package. The
raft module already follows this pattern ({{{}FileRawSnapshotReader{}}},
{{{}FileRawSnapshotWriter{}}}, {{{}Snapshots{}}}, {{{}FileQuorumStateStore{}}},
{{{}KafkaRaftLog{}}}), so there is a directly comparable precedent and no KIP
needed.
Plan to keep this reviewable:
* One PR per file or small cluster, each independently mergeable.
* First PR targets {{{}LazyIndex{}}}, which is called out in the description.
Alongside the IOException-to-UncheckedIOException conversion, it folds in the
constructor cleanup mentioned in the description: replacing {{(IndexWrapper,
long, int, IndexType)}} with {{(IndexWrapper, factoryFunction)}} so
{{loadIndex}} no longer needs the {{@SuppressWarnings("unchecked")}} switch on
{{{}IndexType{}}}. The PR is small enough to act as a pattern PR for reviewer
sign-off before the larger files land.
* Subsequent PRs walk the remaining 17 files in dependency order: leaf indexes
({{{}AbstractIndex{}}}, {{{}OffsetIndex{}}}, {{{}TimeIndex{}}},
{{{}TransactionIndex{}}}, {{{}SnapshotFile{}}}) first, then {{LogSegment}} /
{{LogSegments}} / {{LocalLog}} / {{LogLoader}} / {{UnifiedLog}} /
{{LogManager}} / {{Cleaner}} / {{LogCleanerManager}} / {{ProducerStateManager}}
/ {{RemoteIndexCache}} / {{AsyncOffsetReader}} / {{{}SegmentDeletionReason{}}}.
* Externally visible method signatures stay declared as-is in the first pass.
{{UncheckedIOException}} extends {{RuntimeException}} so dropping a {{throws}}
clause is source- and binary-compatible, but I will keep public callers'
signatures untouched to limit blast radius. Public-surface cleanup belongs in a
separate ticket.
> Consider using UncheckedIOException instead of IOException in the log layer
> ---------------------------------------------------------------------------
>
> Key: KAFKA-14490
> URL: https://issues.apache.org/jira/browse/KAFKA-14490
> Project: Kafka
> Issue Type: Sub-task
> Reporter: Ismael Juma
> Assignee: Canxuan Wang
> Priority: Major
>
> IOException is a checked exception, which makes it difficult to use with
> lambdas. We should consider using UncheckdIOException instead.
> I'll add notes below with code that could be simplified if we did this:
> 1. The private constructor of LazyIndex could take a factory method instead
> of all parameters and IndexType (like the Scala code used to). This would
> avoid some repetition and some unsafe casts.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)