Repository: confluentinc/schema-registry
Pull request #3703: remove unused method to resolve kafka build failure
Author: login: lei-tianyu
Created: 2025-04-25T23:23:24Z | Merged: 2025-04-28T07:16:39Z

<!--
Is there any breaking changes?  If so this is a major release, make sure '#major' is in at least one
commit message to get CI to bump the major.  This will prevent automatic down stream dependency
bumping / consuming.  For more information about semantic versioning see: https://semver.org/


Suggested PR template: Fill/delete/add sections as needed. Optionally delete any commented block.
-->
What
----
<!--
Briefly describe **what** you have changed and **why**.
Optionally include implementation strategy.
-->
https://github.com/apache/kafka/commit/1c82b89b4cf 
https://github.com/apache/kafka/commit/ceac4f0a1d1
two kafka class is removed from the latest, i am removing an unused method in SR to pass the build failure

Checklist
------------------
- [ ] Contains customer facing changes? Including API/behavior changes <!-- This can help identify if it has introduced any breaking changes -->
- [ ] Is this change gated behind feature flag(s)?
    - List the LD flags needed to be set to enable this change
- [ ] Did you add sufficient unit test and/or integration test coverage for this PR?
    - If not, please explain why it is not required
- [ ] Does this change require modifying existing system tests or adding new system tests? <!-- Primarily for changes that could impact CCloud integrations -->
    - If so, include tracking information for the system test changes

References
----------
JIRA:
<!--
Copy&paste links: to Jira ticket, other PRs, issues, Slack conversations...
For code bumps: link to PR, tag or GitHub `/compare/master...master`
-->

Test & Review
------------
<!--
Has it been tested? how?
Copy&paste any handy instructions, steps or requirements that can save time to the reviewer or any reader.
-->

Open questions / Follow-ups
--------------------------
<!--
Optional: anything open to discussion for the reviewer, out of scope, or follow ups.
-->

<!--
Review stakeholders
------------------
<!--
Optional: mention stakeholders or if special context that is required to review.
-->



Diff:
diff --git a/core/src/main/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfig.java b/core/src/main/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfig.java
index aa8da87fe32..0852e256299 100644
--- a/core/src/main/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfig.java
+++ b/core/src/main/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfig.java
@@ -21,15 +21,11 @@
 import io.confluent.rest.NamedURI;
 import io.confluent.rest.RestConfig;
 import io.confluent.rest.RestConfigException;
-import kafka.cluster.Broker;
-import kafka.cluster.EndPoint;
 import org.apache.kafka.common.config.ConfigDef;
 import org.apache.kafka.common.config.ConfigException;
 import org.apache.kafka.common.security.auth.SecurityProtocol;
-import org.apache.kafka.common.utils.Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import scala.jdk.javaapi.CollectionConverters;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -37,7 +33,6 @@
 import java.net.UnknownHostException;
 import java.util.Properties;
 import java.util.List;
-import java.util.LinkedList;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Map;
@@ -890,22 +885,6 @@ public String bootstrapBrokers() {
     );
   }
 
-  static List<String> brokersToEndpoints(List<Broker> brokers) {
-    final List<String> endpoints = new LinkedList<>();
-    for (Broker broker : brokers) {
-      for (EndPoint ep : CollectionConverters.asJavaCollection(broker.endPoints())) {
-        String
-            hostport =
-            ep.host() == null ? ":" + ep.port() : Utils.formatAddress(ep.host(), ep.port());
-        String endpoint = ep.securityProtocol() + "://" + hostport;
-
-        endpoints.add(endpoint);
-      }
-    }
-
-    return endpoints;
-  }
-
   static String endpointsToBootstrapServers(List<String> endpoints, String securityProtocol) {
     final Set<String> supportedSecurityProtocols = new HashSet<>(SecurityProtocol.names());
     if (!supportedSecurityProtocols.contains(securityProtocol.toUpperCase(Locale.ROOT))) {
diff --git a/core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java b/core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java
index 95e38135802..a8b281ae7ab 100644
--- a/core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java
+++ b/core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java
@@ -128,7 +128,8 @@ public ModeUpdateRequest updateMode(
       throw new RestInvalidModeException();
     }
 
-    if (mode == io.confluent.kafka.schemaregistry.storage.Mode.FORWARD) {
+    if (request.getMode()
+            .equals(io.confluent.kafka.schemaregistry.storage.Mode.FORWARD.toString())) {
       if (subject != null) {
         throw new RestInvalidModeException("Forward mode only supported on global level");
       }
diff --git a/core/src/test/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfigTest.java b/core/src/test/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfigTest.java
index a5eaf612c3a..95c593e47c5 100644
--- a/core/src/test/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfigTest.java
+++ b/core/src/test/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfigTest.java
@@ -22,7 +22,6 @@
 import io.confluent.rest.RestConfig;
 import io.confluent.rest.RestConfigException;
 import kafka.Kafka;
-import kafka.cluster.Broker;
 
 import org.apache.kafka.common.config.ConfigException;
 import org.apache.kafka.common.network.ListenerName;
@@ -117,51 +116,6 @@ public void testGetBrokerEndpointsMixed() throws IOException {
     );
   }
 
-  @Test
-  public void testBrokersToEndpoints() {
-    List<Broker> brokersList = new ArrayList<Broker>(4);
-    brokersList
-        .add(new Broker(0, "localhost", 1, new ListenerName("CLIENT"), SecurityProtocol.PLAINTEXT));
-    brokersList.add(new Broker(1,
-        "localhost1",
-        12,
-        ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT),
-        SecurityProtocol.PLAINTEXT
-    ));
-    brokersList.add(new Broker(2,
-        "localhost2",
-        123,
-        new ListenerName("SECURE_REPLICATION"),
-        SecurityProtocol.SASL_PLAINTEXT
-    ));
-    brokersList.add(new Broker(2,
-        "localhost2",
-        123,
-        ListenerName.forSecurityProtocol(SecurityProtocol.SASL_PLAINTEXT),
-        SecurityProtocol.SASL_PLAINTEXT
-    ));
-    brokersList.add(new Broker(3,
-        "localhost3",
-        1234,
-        ListenerName.forSecurityProtocol(SecurityProtocol.SSL),
-        SecurityProtocol.SSL
-    ));
-    List<String> endpointsList = SchemaRegistryConfig.brokersToEndpoints((brokersList));
-
-    List<String> expected = new ArrayList<String>(4);
-    expected.add("PLAINTEXT://localhost:1");
-    expected.add("PLAINTEXT://localhost1:12");
-    expected.add("SASL_PLAINTEXT://localhost2:123");
-    expected.add("SASL_PLAINTEXT://localhost2:123");
-    expected.add("SSL://localhost3:1234");
-
-    assertEquals("Expected the same size list.", expected.size(), endpointsList.size());
-
-    for (int i = 0; i < endpointsList.size(); i++) {
-      assertEquals("Expected a different endpoint", expected.get(i), endpointsList.get(i));
-    }
-  }
-
   @Test
   public void useDeprecatedInterInstanceProtocolIfDefined() throws RestConfigException {
     Properties props = new Properties();


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR removes an unused method and its associated test code to resolve a Kafka build failure and updates a conditional check in the Mode resource.  
- Removed the test method testBrokersToEndpoints in SchemaRegistryConfigTest.java and the unused brokersToEndpoints method in SchemaRegistryConfig.java  
- Updated the condition in ModeResource.java to compare string values instead of using an enum reference

### Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

| File | Description |
| ---- | ----------- |
| core/src/test/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfigTest.java | Removed test for the unused brokersToEndpoints method to align with upstream changes |
| core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java | Updated condition check to compare string values for mode matching |
| core/src/main/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfig.java | Removed the unused brokersToEndpoints method and redundant Kafka dependency imports |


<details>
<summary>Comments suppressed due to low confidence (3)</summary>

**core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java:131**
* Ensure that the string comparison using equals with Mode.FORWARD.toString() is robust against possible case sensitivity issues, and that request.getMode() consistently returns a matching string value.
```
if (request.getMode().equals(io.confluent.kafka.schemaregistry.storage.Mode.FORWARD.toString())) {
```
**core/src/test/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfigTest.java:117**
* Since the test for brokersToEndpoints is removed, verify that the endpoints generation functionality is still appropriately covered by other tests or that a replacement test is provided if needed.
```
public void testBrokersToEndpoints() {
```
**core/src/main/java/io/confluent/kafka/schemaregistry/rest/SchemaRegistryConfig.java:888**
* Confirm that the removal of the brokersToEndpoints method does not affect any dependent functionality elsewhere in the codebase, since the method was removed to resolve a build failure.
```
static List<String> brokersToEndpoints(List<Broker> brokers) {
```
</details>


state: COMMENTED
author_association: NONE
submitted_at: 2025-04-25T23:23:46Z
user: login: rayokota
body: Left a comment, otherwise LGTM
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-25T23:26:18Z
user: login: lei-tianyu
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-25T23:27:13Z

Review comments:
diff_hunk: @@ -128,7 +128,8 @@ public ModeUpdateRequest updateMode(
       throw new RestInvalidModeException();
     }
 
-    if (mode == io.confluent.kafka.schemaregistry.storage.Mode.FORWARD) {
path: core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java
user: login: rayokota
body: Is this change in 8.0.x as well?
created_at: 2025-04-25T23:26:07Z
author_association: MEMBER
diff_hunk: @@ -128,7 +128,8 @@ public ModeUpdateRequest updateMode(
       throw new RestInvalidModeException();
     }
 
-    if (mode == io.confluent.kafka.schemaregistry.storage.Mode.FORWARD) {
path: core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/ModeResource.java
user: login: lei-tianyu
body: no, this is a miss from previous forward pr which is in master (8.1.0) only 
created_at: 2025-04-25T23:27:13Z
author_association: CONTRIBUTOR

PR comments:
user: login: confluent-cla-assistant[bot]
created_at: 2025-04-25T23:23:34Z
body: :tada: All Contributor License Agreements have been signed. Ready to merge. <br/><sub>Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.<sub>
author_association: NONE
user: login: sonarqube-confluent[bot]
created_at: 2025-04-25T23:55:48Z
body: ![Passed](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/QualityGateBadge/passed.svg?sanitize=true)

# Analysis Details
## 2 Issues
- ![Bug](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/bug.svg?sanitize=true) 0 Bugs
- ![Vulnerability](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/vulnerability.svg?sanitize=true) 0 Vulnerabilities
- ![Code Smell](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/code_smell.svg?sanitize=true) 2 Code Smells

## Coverage and Duplications
- ![Coverage](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/CoverageChart/0.svg?sanitize=true) 0.00% Coverage (0.00% Estimated after merge)
- ![Duplications](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/Duplications/NoDuplicationInfo.svg?sanitize=true) No duplication information (2.00% Estimated after merge)

**Project ID:** schema-registry

[View in SonarQube](https://sonarqube.dp.confluent.io/dashboard?id=schema-registry&pullRequest=3703)


author_association: NONE
user: login: sonarqube-confluent[bot]
created_at: 2025-04-26T00:30:26Z
body: ![Passed](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/QualityGateBadge/passed.svg?sanitize=true)

# Analysis Details
## 2 Issues
- ![Bug](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/bug.svg?sanitize=true) 0 Bugs
- ![Vulnerability](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/vulnerability.svg?sanitize=true) 0 Vulnerabilities
- ![Code Smell](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/code_smell.svg?sanitize=true) 2 Code Smells

## Coverage and Duplications
- ![Coverage](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/CoverageChart/0.svg?sanitize=true) 0.00% Coverage (0.00% Estimated after merge)
- ![Duplications](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/Duplications/NoDuplicationInfo.svg?sanitize=true) No duplication information (2.00% Estimated after merge)

**Project ID:** schema-registry

[View in SonarQube](https://sonarqube.dp.confluent.io/dashboard?id=schema-registry&pullRequest=3703)


author_association: NONE
user: login: sonarqube-confluent[bot]
created_at: 2025-04-27T05:36:01Z
body: ![Passed](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/QualityGateBadge/passed.svg?sanitize=true)

# Analysis Details
## 2 Issues
- ![Bug](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/bug.svg?sanitize=true) 0 Bugs
- ![Vulnerability](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/vulnerability.svg?sanitize=true) 0 Vulnerabilities
- ![Code Smell](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/code_smell.svg?sanitize=true) 2 Code Smells

## Coverage and Duplications
- ![Coverage](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/CoverageChart/0.svg?sanitize=true) 0.00% Coverage (0.00% Estimated after merge)
- ![Duplications](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/Duplications/NoDuplicationInfo.svg?sanitize=true) No duplication information (2.00% Estimated after merge)

**Project ID:** schema-registry

[View in SonarQube](https://sonarqube.dp.confluent.io/dashboard?id=schema-registry&pullRequest=3703)


author_association: NONE
user: login: sonarqube-confluent[bot]
created_at: 2025-04-27T07:36:32Z
body: ![Passed](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/QualityGateBadge/passed.svg?sanitize=true)

# Analysis Details
## 2 Issues
- ![Bug](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/bug.svg?sanitize=true) 0 Bugs
- ![Vulnerability](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/vulnerability.svg?sanitize=true) 0 Vulnerabilities
- ![Code Smell](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/common/code_smell.svg?sanitize=true) 2 Code Smells

## Coverage and Duplications
- ![Coverage](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/CoverageChart/0.svg?sanitize=true) 0.00% Coverage (0.00% Estimated after merge)
- ![Duplications](https://sonarqube.dp.confluent.io/static/communityBranchPlugin/checks/Duplications/NoDuplicationInfo.svg?sanitize=true) No duplication information (2.00% Estimated after merge)

**Project ID:** schema-registry

[View in SonarQube](https://sonarqube.dp.confluent.io/dashboard?id=schema-registry&pullRequest=3703)


author_association: NONE