mimaison commented on code in PR #21976: URL: https://github.com/apache/kafka/pull/21976#discussion_r3235647350
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/SourceConnectorWithInternalConfig.java: ########## @@ -0,0 +1,63 @@ +/* + * 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.connect.runtime; + +import org.apache.kafka.common.config.ConfigDef; +import org.apache.kafka.connect.connector.Task; +import org.apache.kafka.connect.source.SourceConnector; + +import java.util.List; +import java.util.Map; + +/** Test-only source connector including one internal {@link org.apache.kafka.common.config.ConfigDef} key. */ Review Comment: Could we add an internal config to one of the existing SampleConnector classes? ########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Herder.java: ########## @@ -317,9 +317,9 @@ default void validateConnectorConfig(Map<String, String> connectorConfig, Callba /** - * Returns the configuration of a plugin + * Returns the non-internal configuration of a plugin. Review Comment: I don't know if we need to update this javadoc. It's kind of implied that internal configurations are not exposed. ########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java: ########## @@ -1141,6 +1141,23 @@ public void testTransformationPluginConfig() throws ClassNotFoundException { ); } + @Test + public void testConnectorPluginConfigOmitsInternalKeys() throws Exception { + String pluginName = "source-with-internal"; + Class<?> pluginClass = Class.forName("org.apache.kafka.connect.runtime.SourceConnectorWithInternalConfig"); + AbstractHerder herder = testHerder(); + + when(plugins.pluginClass(pluginName, null)).then(invocation -> pluginClass); + when(plugins.newPlugin(anyString(), any())).then(invocation -> pluginClass.getDeclaredConstructor().newInstance()); + when(herder.plugins()).thenReturn(plugins); + + List<ConfigKeyInfo> configs = herder.connectorPluginConfig(pluginName); + assertTrue(configs.stream().anyMatch(c -> c.name().equals("required"))); + // any internal config keys should not be exposed + assertFalse(configs.stream().anyMatch(c -> c.name().equals("internal.only.config"))); Review Comment: Can we use the `INTERNAL_ONLY_CONFIG_KEY` constant instead of hardcoding the config name? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
