akashchamp opened a new pull request, #7490: URL: https://github.com/apache/shenyu/pull/7490
Fixes #7466 JDK proxies send `toString`, `hashCode` and `equals` to the invocation handler too. `ShenyuClientInvocationHandler` only knows the methods parsed from the client interface, so these hit the "method cannot be called" branch and threw `ShenyuException` (e.g. when logging the client or putting it in a `HashSet`). The handler now answers `Object` methods itself: identity-based `equals`/`hashCode`, and a `toString` with the interface name, client name and url. Nothing else in the request path changes. Testing: - Added `ShenyuClientObjectMethodsTest`. On master both tests fail with `ShenyuException: ... method hashCode` / `method toString`; with the fix they pass. It builds the context directly instead of going through `AbstractProxyTest#init`, so it is not limited to JDK < 16 like the existing proxy tests. - `./mvnw -pl shenyu-sdk/shenyu-sdk-spring test` (with checkstyle): 35 tests, 0 failures, 4 skipped (existing JRE-range skips). - Manually in jshell on the module classpath: `toString` gives `...AbstractProxyTest$InvocationClient(name=invocationClient, url=http://invocationClient)`, `hashCode` matches `System.identityHashCode`, `equals` is true for itself and false otherwise, and the mocked `ShenyuSdkClient` saw no calls. Make sure that: - [x] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide). - [x] You submit test cases (unit or integration tests) that back your changes. - [ ] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`. (ran the affected module only, see above) -- 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]
