chia7712 commented on code in PR #20248:
URL: https://github.com/apache/kafka/pull/20248#discussion_r2344066126


##########
server-common/src/main/java/org/apache/kafka/server/common/MetadataVersion.java:
##########
@@ -353,10 +356,24 @@ public static MetadataVersion fromVersionString(String 
versionString) {
         } else {
             key = String.join(".", Arrays.copyOfRange(versionSegments, 0, 
numSegments));
         }
-        return Optional.ofNullable(IBP_VERSIONS.get(key)).orElseThrow(() ->
-            new IllegalArgumentException("Version " + versionString + " is not 
a valid version. The minimum version is " + MINIMUM_VERSION
-                + " and the maximum version is " + latestTesting())
-        );
+        String errorMsg = "Unknown metadata.version '" + versionString + "'. 
Supported metadata.version are: "
+            + metadataVersionsToString(MetadataVersion.MINIMUM_VERSION,
+            unstableFeatureVersionsEnabled ? MetadataVersion.latestTesting() : 
MetadataVersion.latestProduction());
+
+        MetadataVersion metadataVersion = IBP_VERSIONS.get(key);
+        if (metadataVersion == null) {

Review Comment:
   Could you please merge those conditions? for instance:
   ```java
           if (metadataVersion == null || (!unstableFeatureVersionsEnabled && 
!metadataVersion.isProduction())) {
               throw new IllegalArgumentException(errorMsg);
           }
   ```



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