You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2024/12/18 17:00:12 UTC
(kafka) branch 4.0 updated: KAFKA-18264 Remove NotLeaderForPartitionException (#18211)
This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/4.0 by this push:
new 5a6e1204dd5 KAFKA-18264 Remove NotLeaderForPartitionException (#18211)
5a6e1204dd5 is described below
commit 5a6e1204dd533af9f6f8072fe80330c5ea9f6fa7
Author: Nick Guo <la...@gmail.com>
AuthorDate: Thu Dec 19 00:56:13 2024 +0800
KAFKA-18264 Remove NotLeaderForPartitionException (#18211)
Reviewers: Yung <yu...@gmail.com>, Mickael Maison <mi...@gmail.com>, Chia-Ping Tsai <ch...@gmail.com>
---
.../errors/NotLeaderForPartitionException.java | 44 ----------------------
.../errors/NotLeaderOrFollowerException.java | 3 +-
.../main/scala/kafka/server/ReplicaManager.scala | 2 +-
docs/upgrade.html | 3 ++
4 files changed, 5 insertions(+), 47 deletions(-)
diff --git a/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderForPartitionException.java b/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderForPartitionException.java
deleted file mode 100644
index 30efc49dc75..00000000000
--- a/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderForPartitionException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.kafka.common.errors;
-
-/**
- * This server is not the leader for the given partition.
- * @deprecated since 2.6. Use {@link NotLeaderOrFollowerException}.
- */
-@Deprecated
-public class NotLeaderForPartitionException extends InvalidMetadataException {
-
- private static final long serialVersionUID = 1L;
-
- public NotLeaderForPartitionException() {
- super();
- }
-
- public NotLeaderForPartitionException(String message) {
- super(message);
- }
-
- public NotLeaderForPartitionException(Throwable cause) {
- super(cause);
- }
-
- public NotLeaderForPartitionException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderOrFollowerException.java b/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderOrFollowerException.java
index 2db960b738e..c45f158e699 100644
--- a/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderOrFollowerException.java
+++ b/clients/src/main/java/org/apache/kafka/common/errors/NotLeaderOrFollowerException.java
@@ -24,8 +24,7 @@ package org.apache.kafka.common.errors;
* satisfied by a leader or follower, this exception indicates that the broker is not a replica
* of the topic partition.
*/
-@SuppressWarnings("deprecation")
-public class NotLeaderOrFollowerException extends NotLeaderForPartitionException {
+public class NotLeaderOrFollowerException extends InvalidMetadataException {
private static final long serialVersionUID = 1L;
diff --git a/core/src/main/scala/kafka/server/ReplicaManager.scala b/core/src/main/scala/kafka/server/ReplicaManager.scala
index 292b0fd70a0..bba8cdcd36c 100644
--- a/core/src/main/scala/kafka/server/ReplicaManager.scala
+++ b/core/src/main/scala/kafka/server/ReplicaManager.scala
@@ -1921,7 +1921,7 @@ class ReplicaManager(val config: KafkaConfig,
val offset = fetchInfo.fetchOffset
// In case of offset out of range errors, handle it for tiered storage only if all the below conditions are true.
// 1) remote log manager is enabled and it is available
- // 2) `log` instance should not be null here as that would have been caught earlier with NotLeaderForPartitionException or ReplicaNotAvailableException.
+ // 2) `log` instance should not be null here as that would have been caught earlier with NotLeaderOrFollowerException or ReplicaNotAvailableException.
// 3) fetch offset is within the offset range of the remote storage layer
if (remoteLogManager.isDefined && log != null && log.remoteLogEnabled() &&
log.logStartOffset <= offset && offset < log.localLogStartOffset())
diff --git a/docs/upgrade.html b/docs/upgrade.html
index 98b6587e76b..fa420edd2cd 100644
--- a/docs/upgrade.html
+++ b/docs/upgrade.html
@@ -50,6 +50,9 @@
<li>The <code>org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerValidatorCallbackHandler</code> class was removed.
Please use the <code>org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallbackHandler</code> class instead.
</li>
+ <li>The <code>org.apache.kafka.common.errors.NotLeaderForPartitionException</code> class was removed. The <code>org.apache.kafka.common.errors.NotLeaderOrFollowerException</code> is returned
+ if a request could not be processed because the broker is not the leader or follower for a topic partition.
+ </li>
</ul>
</li>
<li><b>Broker</b>