saravanakumar1987 opened a new pull request, #30014: URL: https://github.com/apache/camel/pull/30014
# Description Fixes [CAMEL-26972](https://issues.apache.org/jira/browse/CAMEL-26972). ## What was wrong `parent/pom.xml` manages `com.aliyun:tea-openapi` (0.3.20) and `com.aliyun:tea`, but not `com.aliyun:tea-util`. Each component therefore resolved the tea-util that its Alibaba Cloud SDK declares, not the 0.2.28 that tea-openapi 0.3.20 declares, while the components that use tea-openapi (all but eventbridge) resolved tea-openapi at the managed 0.3.20: | Module | SDK | tea-util resolved | |---|---|---| | camel-alibaba-fc | fc_open20210406 2.1.0 | 0.2.23 | | camel-alibaba-sms | dysmsapi20170525 4.6.0 | 0.2.26 | | camel-alibaba-sls | sls20201230 5.18.1 | 0.2.26 | | camel-alibaba-kms | kms20160120 2.3.2 | 0.2.28 | | camel-alibaba-eventbridge | eventbridge-client 1.3.14 | 0.2.28, from the range `[0.2.7, 1.0.0)` | `com.aliyun.teaopenapi.Client.doRequest` of tea-openapi 0.3.20, which the Function Compute and Short Message Service clients call through `callApi`, reads `RuntimeOptions.domain` before it sends a request, and `RuntimeOptions.returnErrorResponse` after any response. tea-util 0.2.23 has neither field, and 0.2.26 lacks `returnErrorResponse`. So, in the Camel build and the module tests, where the dependencyManagement of camel-parent applies to the dependencies of the SDKs: - camel-alibaba-fc: every request failed before it was sent, with `java.lang.NoSuchFieldError: Class com.aliyun.teautil.models.RuntimeOptions does not have member field 'java.lang.String domain'`. - camel-alibaba-sms: every request that got an HTTP response, also with status 200, failed with the same error for `'java.lang.Boolean returnErrorResponse'`. camel-alibaba-sls was not affected, because its SDK calls `execute`, which does not read `returnErrorResponse`, and kms already resolved 0.2.28. A Maven 3 application that depends on one of these components resolves the tea-openapi and tea-util that the SDK declares (for fc: tea-openapi 0.3.8 with tea-util 0.2.23), because the dependencyManagement of camel-parent does not reach it. It is not affected, and this change does not alter what it resolves. The `camel-spring-boot-dependencies` BOM has the same managed versions (in 4.23.0: tea-openapi 0.3.17 and tea 1.4.2, and no tea-util), so an application that imports that BOM resolves the failing combination (read from the BOM, not run). Every existing test of these modules that sends an exchange uses a Mockito mock of the SDK client, so none of them could show the defect. ## The change `parent/pom.xml` gets the property `tea-util-version` with the value 0.2.28, after `tea-openapi-version`, and a dependencyManagement entry for `com.aliyun:tea-util` that uses it, after the entry of `com.aliyun:tea-openapi`. 0.2.28 is the tea-util version that tea-openapi 0.3.20 declares. The entry is in the `camel components` block, which `PrepareComponentMojo` rewrites in sorted order whenever the generate step of a component runs. It sorts directly after tea-openapi: the generate step ran in each module build below and left `parent/pom.xml` unchanged. The Dependabot group `Aliyun` (`com.aliyun:*`) covers the new entry. As for the managed `com.aliyun:tea` that f0de73f7a63e added, no other pom and no generated file needs to change. ## Classpath changes The test classpaths of the modules, from `mvn dependency:build-classpath -Dmdep.includeScope=test` before and after the change. tea-util 0.2.28 declares json-path 2.10.0, which brings json-smart 2.6.0 and accessors-smart 2.6.0; asm comes with accessors-smart, at the version that camel-parent manages: | Module | Before | After | |---|---|---| | camel-alibaba-fc | tea-util 0.2.23 | tea-util 0.2.28, and new: json-path 2.10.0, json-smart 2.6.0, accessors-smart 2.6.0, asm 9.11.1 | | camel-alibaba-sms, camel-alibaba-sls | tea-util 0.2.26, json-path 2.9.0, json-smart 2.5.0, accessors-smart 2.5.0 | tea-util 0.2.28, json-path 2.10.0, json-smart 2.6.0, accessors-smart 2.6.0 | | camel-alibaba-kms, camel-alibaba-eventbridge | unchanged | unchanged | `mvn dependency:tree -Dincludes=com.aliyun:tea-util` finds no tea-util in camel-alibaba-mns, camel-alibaba-oss and camel-alibaba-ots. Apart from the dependencyManagement of `parent/pom.xml`, only the poms in `components/camel-alibaba` declare `com.aliyun` artifacts. ## Tests Two new tests, `InvokeFunctionRealClientTest` in camel-alibaba-fc and `SendSmsRealClientTest` in camel-alibaba-sms. Each starts a JDK `HttpServer` on 127.0.0.1 with a free port, creates the SDK client with a `Config` that sets the protocol to HTTP and the endpoint to that server, and gives the client to the endpoint through its client option (`fcClient`, `smsClient`). It sends one exchange through the producer and checks that it succeeds: the response holds the status code 200 and the payload (fc) or the code `OK` (sms) that the server answered, and the server received one request, with the action `InvokeFunction` or `SendSms`. ## How it was verified - Without the change of `parent/pom.xml`, each new test fails with the error of the ticket, wrapped in a `CamelExecutionException`: - fc: `java.lang.NoSuchFieldError: Class com.aliyun.teautil.models.RuntimeOptions does not have member field 'java.lang.String domain'` at `com.aliyun.teaopenapi.Client.doRequest(Client.java:1002)`, reached through `callApi` from `com.aliyun.fc_open20210406.Client.invokeFunctionWithOptions(Client.java:2263)`; - sms: the same error for `'java.lang.Boolean returnErrorResponse'` at `com.aliyun.teaopenapi.Client.doRequest(Client.java:1176)`, reached through `callApi` from `com.aliyun.dysmsapi20170525.Client.sendSmsWithOptions(Client.java:5263)`. - With the change, both pass. - With the change, all tests of the five modules pass: camel-alibaba-fc 10, camel-alibaba-sms 2, camel-alibaba-kms 9, camel-alibaba-sls 10 and camel-alibaba-eventbridge 36, with no failure, error or rerun. ## camel-4.23.x The branch `camel-4.23.x` has the same managed versions as the release 4.23.0: tea-openapi 0.3.17, which also declares tea-util 0.2.28, and no tea-util. With kms20160120 2.3.0 there, which declares tea-util 0.2.26, camel-alibaba-kms fails in the build of that branch as well as fc and sms. The same two additions are needed there: a cherry-pick of this commit conflicts only on the line next to the new property, which is `<tea-openapi-version>0.3.17</tea-openapi-version>` on that branch. That branch was not built or tested here. # 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). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I have run `mvn clean install -Dquickly -DskipTests` from the root folder on upstream `main` (31e144597200, the parent of this commit), and then, with the change, `mvn test` in camel-alibaba-fc, -sms, -kms, -sls and -eventbridge, which also runs their code generators (including the sync of `parent/pom.xml`), the formatter and the import sorter. They changed no file, so there are no auto-generated changes to commit. The commands that were run: ``` # in components/camel-alibaba/camel-alibaba-fc and camel-alibaba-sms, before and after the change of parent/pom.xml mvn -B -nsu -Ddevelocity.scan.disabled=true test -Dtest=InvokeFunctionRealClientTest -Dsurefire.rerunFailingTestsCount=0 -DtrimStackTrace=false mvn -B -nsu -Ddevelocity.scan.disabled=true test -Dtest=SendSmsRealClientTest -Dsurefire.rerunFailingTestsCount=0 -DtrimStackTrace=false # in each of camel-alibaba-fc, -sms, -kms, -sls and -eventbridge, with the change mvn -B -nsu -Ddevelocity.scan.disabled=true test # in the same five modules, before and after the change mvn -q -B -nsu -Ddevelocity.scan.disabled=true dependency:build-classpath -Dmdep.includeScope=test -Dmdep.outputFile=<file> # in the same five modules, with the change mvn -B -nsu -Ddevelocity.scan.disabled=true dependency:tree -Dincludes=com.aliyun:tea-util -Dverbose # in camel-alibaba-mns, -oss and -ots, with the change mvn -B -nsu -Ddevelocity.scan.disabled=true dependency:tree -Dincludes=com.aliyun:tea-util ``` # 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. The change, the tests and this text were drafted with Claude Code (Anthropic), from the investigation behind the ticket. The tests and the classpath comparison were run as listed above. The change and this text were checked by independent AI reviews. _Claude Code on behalf of saravanakumar1987_ 🤖 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]
