Yunyung commented on code in PR #17980:
URL: https://github.com/apache/kafka/pull/17980#discussion_r1863826675


##########
core/src/main/java/kafka/server/share/SharePartitionManager.java:
##########
@@ -294,17 +294,27 @@ public CompletableFuture<Map<TopicIdPartition, 
ShareAcknowledgeResponseData.Part
 
                 futures.put(topicIdPartition, future);
             } else {
-                futures.put(topicIdPartition, 
CompletableFuture.completedFuture(Errors.UNKNOWN_TOPIC_OR_PARTITION));
+                futures.put(topicIdPartition, 
CompletableFuture.completedFuture(Errors.UNKNOWN_TOPIC_OR_PARTITION.exception()));
             }
         });
 
         CompletableFuture<Void> allFutures = CompletableFuture.allOf(
             futures.values().toArray(new CompletableFuture[0]));
         return allFutures.thenApply(v -> {
             Map<TopicIdPartition, ShareAcknowledgeResponseData.PartitionData> 
result = new HashMap<>();
-            futures.forEach((topicIdPartition, future) -> 
result.put(topicIdPartition, new ShareAcknowledgeResponseData.PartitionData()
-                .setPartitionIndex(topicIdPartition.partition())
-                .setErrorCode(future.join().code())));
+            futures.forEach((topicIdPartition, future) -> {
+                ShareAcknowledgeResponseData.PartitionData partitionData = new 
ShareAcknowledgeResponseData.PartitionData()
+                        .setPartitionIndex(topicIdPartition.partition());
+                Throwable t = future.join();
+                if (t == null) {
+                    partitionData.setErrorCode(Errors.NONE.code())
+                            .setErrorMessage(Errors.NONE.message());

Review Comment:
   ditto



##########
core/src/main/java/kafka/server/share/SharePartitionManager.java:
##########
@@ -294,17 +294,27 @@ public CompletableFuture<Map<TopicIdPartition, 
ShareAcknowledgeResponseData.Part
 
                 futures.put(topicIdPartition, future);
             } else {
-                futures.put(topicIdPartition, 
CompletableFuture.completedFuture(Errors.UNKNOWN_TOPIC_OR_PARTITION));
+                futures.put(topicIdPartition, 
CompletableFuture.completedFuture(Errors.UNKNOWN_TOPIC_OR_PARTITION.exception()));
             }
         });
 
         CompletableFuture<Void> allFutures = CompletableFuture.allOf(
             futures.values().toArray(new CompletableFuture[0]));
         return allFutures.thenApply(v -> {
             Map<TopicIdPartition, ShareAcknowledgeResponseData.PartitionData> 
result = new HashMap<>();
-            futures.forEach((topicIdPartition, future) -> 
result.put(topicIdPartition, new ShareAcknowledgeResponseData.PartitionData()
-                .setPartitionIndex(topicIdPartition.partition())
-                .setErrorCode(future.join().code())));
+            futures.forEach((topicIdPartition, future) -> {
+                ShareAcknowledgeResponseData.PartitionData partitionData = new 
ShareAcknowledgeResponseData.PartitionData()
+                        .setPartitionIndex(topicIdPartition.partition());
+                Throwable t = future.join();
+                if (t == null) {
+                    partitionData.setErrorCode(Errors.NONE.code())

Review Comment:
   For this kind of class, I’ve noticed that in some places, we check if the 
error is Errors.NONE.code()
   https://github.com/search?q=repo%3Aapache%2Fkafka+Errors.NONE.code&type=code
   I’m not sure if this is the convention, but I’ve followed the previous code 
and made no changes here as well. However, setErrorMessage should not be 
necessary for this case; I’ve removed it.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to