abbccdda commented on a change in pull request #9600:
URL: https://github.com/apache/kafka/pull/9600#discussion_r557810929



##########
File path: clients/src/main/java/org/apache/kafka/clients/NodeApiVersions.java
##########
@@ -123,21 +125,25 @@ public short latestUsableVersion(ApiKeys apiKey) {
      * Get the latest version supported by the broker within an allowed range 
of versions
      */
     public short latestUsableVersion(ApiKeys apiKey, short 
oldestAllowedVersion, short latestAllowedVersion) {
-        ApiVersion usableVersion = supportedVersions.get(apiKey);
-        if (usableVersion == null)
-            throw new UnsupportedVersionException("The broker does not support 
" + apiKey);
-        return latestUsableVersion(apiKey, usableVersion, 
oldestAllowedVersion, latestAllowedVersion);
+        return latestUsableVersion(apiKey, supportedVersions.get(apiKey), 
oldestAllowedVersion, latestAllowedVersion);
     }
 
-    private short latestUsableVersion(ApiKeys apiKey, ApiVersion 
supportedVersions,
-                                      short minAllowedVersion, short 
maxAllowedVersion) {
-        short minVersion = (short) Math.max(minAllowedVersion, 
supportedVersions.minVersion);
-        short maxVersion = (short) Math.min(maxAllowedVersion, 
supportedVersions.maxVersion);
-        if (minVersion > maxVersion)
+    private short latestUsableVersion(ApiKeys apiKey,
+                                      ApiVersion supportedVersions,
+                                      short minAllowedVersion,
+                                      short maxAllowedVersion) {
+        if (supportedVersions == null)

Review comment:
       Yea, actually we could remove the private function since it becomes 
single caller.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to