AndrewJSchofield commented on code in PR #18053:
URL: https://github.com/apache/kafka/pull/18053#discussion_r1871156905
##########
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());
try {
// Re-check the state to verify if previous requests has already
initialized the share partition.
maybeCompleteInitialization(future);
Review Comment:
It seems to me that `maybeCompleteInitialization` should not complete the
future under the write lock either. It could return an exception which is then
places into the `futureException` and then the future is completed in the
finally block.
##########
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'm not convinced that you need an `Optional` in here. This gives you three
options: null, Optional.empty, and a non-empty Optional. If you just need two,
wouldn't `Optional<Throwable>` be slightly less cumbersome?
--
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]