From ec84fa3885fbb46618e2a0121e177337d306c835 Mon Sep 17 00:00:00 2001 From: Dung Ha Date: Wed, 31 Jan 2024 02:26:27 -0500 Subject: [PATCH 1/3] Omit a dot in the complete error message --- .../org/apache/kafka/clients/producer/internals/Sender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java b/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java index 01f49ffad0903..62c483d2af90b 100644 --- a/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java +++ b/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java @@ -704,7 +704,7 @@ private void completeBatch(ProducerBatch batch, ProduceResponse.PartitionRespons "topic-partition may not exist or the user may not have Describe access to it", batch.topicPartition); } else { - log.warn("Received invalid metadata error in produce request on partition {} due to {}. Going " + + log.warn("Received invalid metadata error in produce request on partition {} due to {} Going " + "to request metadata update now", batch.topicPartition, error.exception(response.errorMessage).toString()); } From 891977b14ccb1a921f0f0f486adb0138f334a3c0 Mon Sep 17 00:00:00 2001 From: Dung Ha Date: Fri, 9 Feb 2024 16:53:39 -0500 Subject: [PATCH 2/3] add code to make appropriate change to the error message in case it ends with "." --- .../org/apache/kafka/clients/producer/internals/Sender.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java b/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java index 62c483d2af90b..890c612af0b16 100644 --- a/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java +++ b/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java @@ -704,9 +704,10 @@ private void completeBatch(ProducerBatch batch, ProduceResponse.PartitionRespons "topic-partition may not exist or the user may not have Describe access to it", batch.topicPartition); } else { + String errorMessage = error.exception(response.errorMessage).toString(); + errorMessage = (errorMessage.endsWith(".")) ? errorMessage : (errorMessage + "."); log.warn("Received invalid metadata error in produce request on partition {} due to {} Going " + - "to request metadata update now", batch.topicPartition, - error.exception(response.errorMessage).toString()); + "to request metadata update now", batch.topicPartition, errorMessage); } if (error.exception() instanceof NotLeaderOrFollowerException || error.exception() instanceof FencedLeaderEpochException) { log.debug("For {}, received error {}, with leaderIdAndEpoch {}", batch.topicPartition, error, response.currentLeader); From 39b64da319bea0f32c2b1a414d7814ed19ac0844 Mon Sep 17 00:00:00 2001 From: Dung Ha Date: Fri, 16 Feb 2024 16:46:15 -0500 Subject: [PATCH 3/3] Editted log message to simply code. Added dots to "defaultExceptionString" that had not already ended with a full stop, for some errors. --- .../kafka/clients/producer/internals/Sender.java | 4 +--- .../org/apache/kafka/common/protocol/Errors.java | 12 ++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java b/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java index 890c612af0b16..f70c5516a946a 100644 --- a/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java +++ b/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java @@ -704,10 +704,8 @@ private void completeBatch(ProducerBatch batch, ProduceResponse.PartitionRespons "topic-partition may not exist or the user may not have Describe access to it", batch.topicPartition); } else { - String errorMessage = error.exception(response.errorMessage).toString(); - errorMessage = (errorMessage.endsWith(".")) ? errorMessage : (errorMessage + "."); log.warn("Received invalid metadata error in produce request on partition {} due to {} Going " + - "to request metadata update now", batch.topicPartition, errorMessage); + "to request metadata update now", batch.topicPartition, error.exception(response.errorMessage).toString()); } if (error.exception() instanceof NotLeaderOrFollowerException || error.exception() instanceof FencedLeaderEpochException) { log.debug("For {}, received error {}, with leaderIdAndEpoch {}", batch.topicPartition, error, response.currentLeader); diff --git a/clients/src/main/java/org/apache/kafka/common/protocol/Errors.java b/clients/src/main/java/org/apache/kafka/common/protocol/Errors.java index 838be869f6a07..610b1b66e7633 100644 --- a/clients/src/main/java/org/apache/kafka/common/protocol/Errors.java +++ b/clients/src/main/java/org/apache/kafka/common/protocol/Errors.java @@ -363,12 +363,12 @@ public enum Errors { DUPLICATE_RESOURCE(92, "A request illegally referred to the same resource twice.", DuplicateResourceException::new), UNACCEPTABLE_CREDENTIAL(93, "Requested credential would not meet criteria for acceptability.", UnacceptableCredentialException::new), INCONSISTENT_VOTER_SET(94, "Indicates that the either the sender or recipient of a " + - "voter-only request is not one of the expected voters", InconsistentVoterSetException::new), + "voter-only request is not one of the expected voters.", InconsistentVoterSetException::new), INVALID_UPDATE_VERSION(95, "The given update version was invalid.", InvalidUpdateVersionException::new), FEATURE_UPDATE_FAILED(96, "Unable to update finalized features due to an unexpected server error.", FeatureUpdateFailedException::new), PRINCIPAL_DESERIALIZATION_FAILURE(97, "Request principal deserialization failed during forwarding. " + "This indicates an internal error on the broker cluster security setup.", PrincipalDeserializationException::new), - SNAPSHOT_NOT_FOUND(98, "Requested snapshot was not found", SnapshotNotFoundException::new), + SNAPSHOT_NOT_FOUND(98, "Requested snapshot was not found.", SnapshotNotFoundException::new), POSITION_OUT_OF_RANGE( 99, "Requested position is not greater than or equal to zero, and less than the size of the snapshot.", @@ -376,10 +376,10 @@ public enum Errors { UNKNOWN_TOPIC_ID(100, "This server does not host this topic ID.", UnknownTopicIdException::new), DUPLICATE_BROKER_REGISTRATION(101, "This broker ID is already in use.", DuplicateBrokerRegistrationException::new), BROKER_ID_NOT_REGISTERED(102, "The given broker ID was not registered.", BrokerIdNotRegisteredException::new), - INCONSISTENT_TOPIC_ID(103, "The log's topic ID did not match the topic ID in the request", InconsistentTopicIdException::new), - INCONSISTENT_CLUSTER_ID(104, "The clusterId in the request does not match that found on the server", InconsistentClusterIdException::new), - TRANSACTIONAL_ID_NOT_FOUND(105, "The transactionalId could not be found", TransactionalIdNotFoundException::new), - FETCH_SESSION_TOPIC_ID_ERROR(106, "The fetch session encountered inconsistent topic ID usage", FetchSessionTopicIdException::new), + INCONSISTENT_TOPIC_ID(103, "The log's topic ID did not match the topic ID in the request.", InconsistentTopicIdException::new), + INCONSISTENT_CLUSTER_ID(104, "The clusterId in the request does not match that found on the server.", InconsistentClusterIdException::new), + TRANSACTIONAL_ID_NOT_FOUND(105, "The transactionalId could not be found.", TransactionalIdNotFoundException::new), + FETCH_SESSION_TOPIC_ID_ERROR(106, "The fetch session encountered inconsistent topic ID usage.", FetchSessionTopicIdException::new), INELIGIBLE_REPLICA(107, "The new ISR contains at least one ineligible replica.", IneligibleReplicaException::new), NEW_LEADER_ELECTED(108, "The AlterPartition request successfully updated the partition state but the leader has changed.", NewLeaderElectedException::new), OFFSET_MOVED_TO_TIERED_STORAGE(109, "The requested offset is moved to tiered storage.", OffsetMovedToTieredStorageException::new),