allthingssecurity opened a new pull request, #31012: URL: https://github.com/apache/camel/pull/31012
# Description [CAMEL-27626](https://issues.apache.org/jira/browse/CAMEL-27626) The ticket lists three problems of camel-xchange that came up while the option descriptions were written for CAMEL-23832 (#30957). I checked each one against main. All three are fixed here. Fixed: 1. **currencyPair accepted an unknown currency.** `XChangeConfiguration.getAsCurrencyPair()` parsed the option with `new CurrencyPair(String)` for every message, and that registers an unknown currency in the JVM wide registry of XChange, so a typo such as `BTC/USTD` was sent to the exchange. `getAsCurrencyPair()` now uses `XChangeConverters.toCurrencyPair(String)`, which does not register currencies, and `XChangeComponent.createEndpoint()` calls it once, so an unknown currency fails the creation of the endpoint, in the same way as the `currency` option. The check runs after the exchange is created, as an exchange module can register the currencies that it trades when it is created, and those must keep working. Both parsers take the same separators and are not case-sensitive (checked with javap on xchange-core 6.0.0). The option stays a `String`, so `getCurrencyPair()` and `setCurrencyPair(String)` do not change. As the ticket says, `XChangeConfiguration.setCurrency(String)` is not called by the configurer and sets null for an unknown currency. It is public, so I deprecated it rather than removing it. 2. **The doc page promised trading and historical data.** The introduction now says what the component does (the ticker, the currencies and currency pairs with their metadata, and the balances, wallets and funding history of an account), and that it does not place orders or query historical market data. The `:description:` line is the one #30957 changed, so I left it. 3. **The API keys could be set only through a file of the XChange module.** The new `apiKey` and `secretKey` options (label `security`, `security = "secret"`) are passed to `ExchangeFactory.createExchange(Class, String, String)`, which starts from the default `ExchangeSpecification` of the exchange module and sets only the keys that are not null (checked with javap: `createExchange(Class)` is that method with two nulls). The component used to keep one exchange per name, shared by all endpoints of that name. Endpoints without keys still share that one, created in the same way as before, and `getXChange(name)` still returns it. Endpoints with keys get one exchange per name and keys, in a second `ConcurrentHashMap`, so two endpoints with other keys do not share an exchange. The key of that map does not show the keys in its `toString()`. The doc page shows the options, with property placeholders. The behaviour change of 1 and the new options are in the 4.24 upgrade guide, after the entry of camel-xchange that is already there. #30957 (CAMEL-23832, the new descriptions of camel-xchange) is merged, and this branch is rebased on main after it. The only conflicts were in the generated `xchange.json` and its catalog copy; `XChangeConfiguration` and the doc page merged cleanly. I kept the texts of #30957 and regenerated the JSON, the catalog copy, the configurer, the URI factory and the endpoint DSL from the merged sources. No text of #30957 became wrong. I added one sentence to its description of `currencyPair`: "A currency that XChange does not know fails the creation of the endpoint.", the same sentence as in its description of `currency`, since that is now true for both options. Tests: - `XChangeApiKeysCurrencyPairTest` (new): `apiKey` and `secretKey` reach the `ExchangeSpecification`; endpoints with the same keys share an exchange, endpoints with other keys or without keys do not, and `getXChange(name)` returns the one without keys; `currencyPair=BTC/QQZZ` fails the endpoint and does not register `QQZZ`; `currencyPair=btc/CMLK`, where `CMLK` is registered by the exchange module when it is created, is accepted. The exchange is `CamelkeysExchange`, a test module in `org.knowm.xchange.camelkeys` that the component finds by name as it finds the XChange modules, and that makes no remote call. Against the main sources 3 of the 4 fail (the two key tests with "Unknown parameters", and the endpoint with `BTC/QQZZ` is created); the `CMLK` test passes, as that case worked before. Results after the rebase (offline, module build of camel-xchange, test phase, unit tests only): 23 tests run, 0 failures, 0 errors, 9 skipped (the producer tests that are `@Disabled` on main because they call the live Binance API). The new test class passed 5 runs in a row, and against the main sources the same 3 of its 4 tests still fail. Generated files: `xchange.json` of the component and its catalog copy, the catalog copy of the doc page, `XChangeEndpointConfigurer`, `XChangeEndpointUriFactory`, and `XChangeEndpointBuilderFactory` of the endpoint DSL. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-27626](https://issues.apache.org/jira/browse/CAMEL-27626). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-xchange and ran its unit tests, and committed the regenerated component JSON, configurer and URI factory. The catalog copies of the JSON and of the doc page are copies of them (they were identical on main), and the endpoint DSL was regenerated from it with the generate-endpoint-dsl goal of camel-package-maven-plugin, as an offline build of those modules was not possible here. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
