adixitconfluent commented on code in PR #18053:
URL: https://github.com/apache/kafka/pull/18053#discussion_r1871397498
##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -380,6 +381,7 @@ public CompletableFuture<Void> maybeInitialize() {
// All the pending requests should wait to get completed before the
share partition is initialized.
// Attain lock to avoid any concurrent requests to be processed.
lock.writeLock().lock();
+ AtomicReference<Optional<Throwable>> futureException = new
AtomicReference<>(Optional.empty());
Review Comment:
I need to use an `AtomicReference` here since only final or effective final
variables can be passed into `whenComplete` block of `persister.readState`. The
only reason for using `AtomicReference<Optional<Throwable>>` and not
`AtomicReference<Throwable>` is because the exception could be null as well.
Hence, thought using Optional is a better coding standard here.
Regarding the 3 options - null, Optional.empty, and a non-empty Optional, I
initialize `futureException` to Optional.empty() and never use null. Hence,
only dealing with 2 option values here.
I can go ahead and make the change if my reasoning is not satisfactory.
--
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]