davsclaus opened a new pull request, #31020: URL: https://github.com/apache/camel/pull/31020
Fixes [CAMEL-27663](https://issues.apache.org/jira/browse/CAMEL-27663). The device client pool of camel-azure-iothub keyed its clients by the HostName, DeviceId and ModuleId of the connection string only. A connection string of the same device with another key (for example after a key change) reused the pooled client that was opened with the first key, instead of opening its own client. The client pool key must include the credential, so clients for different keys are not shared: - `DeviceClientPool` keys clients by a `PoolKey` record: hub, device and module from the connection string, plus a SHA-256 hash of the whole connection string. The key itself is never stored in the key, and `toString()` (used in log messages) leaves the hash out. Before, a blank device id used the raw connection string as the pool key, which also ended up in log messages. - `remove(deviceId)` closes the clients of all connection strings of the device, and matches the device id on the record field instead of splitting the key on `:` (device ids may contain `:`). - The component doc says connections are pooled per connection string. The component is new in 4.24.0 (CAMEL-22624), so no released version is affected and no upgrade-guide entry is needed. Tests: - `DeviceClientPoolTest`: a connection string with another key, or with no key, does not get the pooled client (a fake factory opens clients only for the right key); a wrong key on an empty pool is rejected; two keys of the same device get their own clients, and `remove` closes both. - `IoTHubComponentTest`: a producer that takes the device and connection string from headers does not use the client opened by another endpoint of the component for a different key. - The three new "different key" tests fail without the fix. `mvn -o install` of the module: 46 tests pass. _Claude Code on behalf of Claus Ibsen_ 🤖 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]
