Andrea Cosentino created CAMEL-24890:
----------------------------------------

             Summary: camel-debezium - deprecated connector options declared as 
String constants are still generated
                 Key: CAMEL-24890
                 URL: https://issues.apache.org/jira/browse/CAMEL-24890
             Project: Camel
          Issue Type: Bug
          Components: camel-debezium
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino


h3. Summary

{{camel-debezium-maven-plugin}} drops options that Debezium has deprecated, but 
only when the
connector declares them as an {{io.debezium.config.Field}}. When the deprecated 
constant is a plain
{{String}}, the filter silently fails and the option is generated anyway.

h3. Details

{{ConnectorConfigFieldsFactory.retrieveDbzFieldWithReflection}}:

{code:java}
} else if (object instanceof String fieldString) {
    String removedDotAndCapitalize = Stream
            .of(fieldString.split("."))
            .map(field -> StringUtils.capitalize(field))
            .collect(Collectors.joining(""));
    return StringUtils.uncapitalize(removedDotAndCapitalize);
{code}

{{split(".")}} takes a regular expression, and {{.}} matches any character, so 
the result is a
zero-length array - {{"database.server.name".split(".").length == 0}}. The 
method returns {{""}}
instead of the option name, the name never enters {{deprecatedFields}}, and
{{ConnectorConfigGenerator.setClassFields()}} generates the field.

h3. Evidence

{{OracleConnectorConfig}} has one deprecated member of each kind, which makes 
the effect directly
observable in the shipped module:

|| upstream {{@Deprecated}} member || declared type || generated by Camel? ||
| {{LOG_MINING_CONTINUOUS_MINE}} | {{io.debezium.config.Field}} | absent - 
filtered correctly |
| {{DEPRECATED_XSTREAM_SERVER_NAME}} = {{"database.out.server.name"}} | 
{{java.lang.String}} | present |

{{OracleConnectorEmbeddedDebeziumConfiguration}} consequently declares 
{{databaseOutServerName}}
next to the current {{xstreamOutServerName}}, and {{debezium-oracle.json}} 
publishes both with the
same description and {{"deprecated": false}}. Users get two catalog options for 
one setting, the
deprecated one is not marked as such, and it will disappear without notice when 
Debezium removes the
constant.

h3. Proposed fix

Use {{split("\\.")}} (or {{Pattern.quote(".")}}), and add a test for the 
{{String}} branch of
{{retrieveDbzFieldWithReflection}} - {{ConnectorConfigFieldsFactoryTest}} 
currently only exercises
the {{Field}} branch. Regenerating {{camel-debezium-oracle}} then drops 
{{databaseOutServerName}},
which is a removed endpoint option and needs an upgrade-guide entry.

----
_Reported by Claude Code on behalf of oscerd (Andrea Cosentino)._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to