You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "chia7712 (via GitHub)" <gi...@apache.org> on 2025/09/12 12:15:58 UTC
Re: [PR] KAFKA-19544: Improve `MetadataVersion.fromVersionString()` to take an enableUnstableFeature flag [kafka]
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org