apoorvmittal10 commented on code in PR #18093:
URL: https://github.com/apache/kafka/pull/18093#discussion_r1874507257


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -1178,32 +1160,20 @@ private boolean stateNotActive() {
         return  partitionState() != SharePartitionState.ACTIVE;
     }
 
-    private void completeInitializationWithException() {
-        lock.writeLock().lock();
-        try {
-            partitionState = SharePartitionState.FAILED;
-        } finally {
-            lock.writeLock().unlock();
-        }
-    }
-
-    private InitializationResult checkInitializationCompletion() {
+    private boolean initializedOrThrowException() {
         SharePartitionState currentState = partitionState();
-        switch (currentState) {
-            case ACTIVE:
-                return new InitializationResult(true);
-            case FAILED:
-                return new InitializationResult(true, new 
IllegalStateException(String.format("Share partition failed to load %s-%s", 
groupId, topicIdPartition)));
-            case INITIALIZING:
-                return new InitializationResult(true, new 
LeaderNotAvailableException(String.format("Share partition is already 
initializing %s-%s", groupId, topicIdPartition)));
-            case FENCED:
-                return new InitializationResult(true, new 
FencedStateEpochException(String.format("Share partition is fenced %s-%s", 
groupId, topicIdPartition)));
-            case EMPTY:
-                // Do not complete the future as the share partition is not 
yet initialized.
-                return new InitializationResult(false);
-            default:

Review Comment:
   Now code uses `switch type pattern` as minNonClientJavaVersion is set to 17, 
hence that doesn't require default on enum. If new enum type will be added in 
future but not in switch statement then compile time exception will occur in 
build.



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