jolshan commented on code in PR #14378:
URL: https://github.com/apache/kafka/pull/14378#discussion_r1324872270


##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -753,39 +753,63 @@ class ReplicaManager(val config: KafkaConfig,
         val localProduceResults = appendToLocalLog(internalTopicsAllowed = 
internalTopicsAllowed,
           origin, verifiedEntries, requiredAcks, requestLocal, 
verificationGuards.toMap)
         debug("Produce to local log in %d ms".format(time.milliseconds - 
sTime))
-        
-        val unverifiedResults = unverifiedEntries.map { case (topicPartition, 
error) =>
-          val message = if (error == Errors.INVALID_TXN_STATE) "Partition was 
not added to the transaction" else error.message()
-          topicPartition -> LogAppendResult(
-            LogAppendInfo.UNKNOWN_LOG_APPEND_INFO,
-            Some(error.exception(message))
-          )
-        }
 
-        val errorResults = errorsPerPartition.map { case (topicPartition, 
error) =>
-          topicPartition -> LogAppendResult(
-            LogAppendInfo.UNKNOWN_LOG_APPEND_INFO,
-            Some(error.exception())
-          )
+        def produceStatusResult(appendResult: Map[TopicPartition, 
LogAppendResult],
+                                useCustomMessage: Boolean): 
Map[TopicPartition, ProducePartitionStatus] = {
+          appendResult.map { case (topicPartition, result) =>
+            topicPartition -> ProducePartitionStatus(
+              result.info.lastOffset + 1, // required offset
+              new PartitionResponse(
+                result.error,
+                result.info.firstOffset.map[Long](_.messageOffset).orElse(-1L),
+                result.info.lastOffset,
+                result.info.logAppendTime,
+                result.info.logStartOffset,
+                result.info.recordErrors,
+                if (useCustomMessage) result.exception.get.getMessage else 
result.info.errorMessage

Review Comment:
   Correct -- when we use custom message, we have always used 
LogAppendInfo.UnknownLogAppendInfo.
   
   I'm not sure why it is this way. Perhaps if it is the default error message 
(which was the case previously) we didn't want to bloat the response.



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