You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "chickenchickenlove (via GitHub)" <gi...@apache.org> on 2026/05/04 04:10:18 UTC
[PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
chickenchickenlove opened a new pull request, #22202:
URL: https://github.com/apache/kafka/pull/22202
### Description
This PR implement [KIP-1245](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1245%3A+Enforce+%27application.server%27+%3Cserver%3E%3A%3Cport%3E+format+at+config+level), which enforces the `application.server` host:port format during `StreamsConfig` construction.
### Changes
- Add a `ConfigDef.Validator` for `application.server` to fail fast on invalid values in `StreamsConfig` instead of later in `HostInfo`.
- Update an existing `StreamsConfigTest` case to use a valid `application.server` value.
- Add test coverage for valid and invalid `application.server` values.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3435836951
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
I see.
Thanks for your comments, Nikita and mjsax!
I'll keep it as it is.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4742296795
@mjsax
Thanks for the review!
> Just wondering, if HostInfo#buildFromEndpoint() and the new validator (both duplicate the same code) could be unified?
I've addressed it!
I have a question.
Could you let me know which release this KIP is planned for?
I'd like to update `docs/streams/upgrade-guide.md` accordingly for that release.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4658759352
@mjsax
Sorry to bother you.
When you get a chance, could you take a look?
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3190275366
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+
Review Comment:
nit: extra empty line
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4376206224
@nileshkumar3 Thanks for the time to take a look!
I've addressed it based on your comments.
When you get a chance, please take another look.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3416071449
##########
streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java:
##########
@@ -1866,6 +1866,22 @@ public void shouldLogWarningWhenProcessingExceptionHandlerIsNotEnabledOnGlobalTh
}
}
+ @ParameterizedTest
+ @ValueSource(strings = {"dummy:host", "dummy:9999999999999999999999999", "dummy", "dummy:", ":port"})
Review Comment:
Should we add `":8080"` as one more test? Maybe also `":"` ?
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
> If we want to tighten the regex, I think another KIP is required.
I don't think so. I think the simplest fix would be, to push the `try-catch` into `getPort()` and let it return `null` if a `NumberFormatException` gets thrown? This would still align to the intended semantics of `getPort()` to return `null` if the port is not valid.
This would really just be a simple bug-fix (and messing with the regex-ex is always a mess, so maybe just catching the exception is simpler).
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4368178911
Hi, @Nikita-Shupletsov !
Itβs been a while since we last spoke.
I opened a PR for KIP-1245, which we discussed earlier!
When you get a chance, please take a look πββοΈ
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3190271223
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
it makes sense. would it make sense to tighten the regex instead?
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4387671110
@Nikita-Shupletsov
Thanks for your quick feedback!
I've removed empty line and left reply for your comments!
When you get a chance, please take a look! πββοΈ
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3185812897
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
Review Comment:
nit: some methods from this class are imported statically, some are called via Utils.method
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
Review Comment:
is it worth having it as a singleton?
I checked a few places(e.g. https://github.com/apache/kafka/blob/trunk/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/TopicCreationConfig.java#L128) and it looks like we don't really do that anywhere else
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
do we need to catch NumberFormatException? looks like HOST_PORT_PATTERN already checks that it's exclusively digits
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4379049517
@Nikita-Shupletsov
Thanks for the time to take a look into this PR.
I've addressed it based on your comments!
When you get a chance, please take another look!
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4763974097
@mjsax
Thanks for your comments!
I've added it to docs sections.
Also, I've rebased on the latest trunk because CI was failed due to 1 password error.
When you get a chance, please take another look. πββοΈ
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "nileshkumar3 (via GitHub)" <gi...@apache.org>.
nileshkumar3 commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3185886508
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
The pattern only says the port looks like digits. Integer.parseInt still errors if that number is too big for a int.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "nileshkumar3 (via GitHub)" <gi...@apache.org>.
nileshkumar3 commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3185499348
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (endPoint.isEmpty()) {
Review Comment:
This is redundant , Utils.isBlank(endPoint) covers this.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3188256632
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
When a very large number is provided as the port number, `HOST_PORT_PATTERN.matcher(...)` operates normally. However, when `Integer.parseInt()` is called on such a large number, a `NumberFormatException` is thrown.
While `HostInfo` would have previously thrown a `NumberFormatException` for large numbers as well, we now catch the `NumberFormatException` in order to throw a `ConfigException`, as described in the KIP.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3196496778
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
I am not sure about a KIP for a change that, effectively, fixes a bug.
@mjsax could you please chime in? thank you
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3195206747
##########
streams/src/main/java/org/apache/kafka/streams/internals/ApplicationServerConfigValidator.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.streams.internals;
+
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.utils.Utils;
+
+import static org.apache.kafka.common.utils.Utils.getHost;
+import static org.apache.kafka.common.utils.Utils.getPort;
+
+public class ApplicationServerConfigValidator implements ConfigDef.Validator {
+
+ private static final ConfigDef.Validator INSTANCE = new ApplicationServerConfigValidator();
+
+ public static ConfigDef.Validator getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void ensureValid(final String name, final Object value) {
+ if (!(value instanceof String)) {
+ throw new ConfigException(name + " must be a string");
+ }
+
+ final String endPoint = (String) value;
+
+ if (Utils.isBlank(endPoint)) {
+ return;
+ }
+
+ final String host = getHost(endPoint);
+ final Integer port;
+ try {
+ port = getPort(endPoint);
+ } catch (final NumberFormatException e) {
Review Comment:
It might be better, but I would prefer to do it in other PR.
This is because `Utils.getPort(...)` is not only used for `HostInfo` but also `QuorumConfig`, etc.
If we want to tighten the regex, I think another KIP is required.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22202:
URL: https://github.com/apache/kafka/pull/22202#discussion_r3436032457
##########
streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java:
##########
@@ -1866,6 +1866,22 @@ public void shouldLogWarningWhenProcessingExceptionHandlerIsNotEnabledOnGlobalTh
}
}
+ @ParameterizedTest
+ @ValueSource(strings = {"dummy:host", "dummy:9999999999999999999999999", "dummy", "dummy:", ":port"})
Review Comment:
Thanks for your comments.
I've added them!
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on PR #22202:
URL: https://github.com/apache/kafka/pull/22202#issuecomment-4781731646
Thanks for the KIP and PR. Merged to `trunk`.
--
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
Re: [PR] KAFKA-17164: Enforce 'application.server' : format at config level. [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax merged PR #22202:
URL: https://github.com/apache/kafka/pull/22202
--
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