annhchen89 opened a new pull request, #6244: URL: https://github.com/apache/shenyu/pull/6244
<!-- Describe your PR here; e.g. Fixes #issueNo --> ### **What is the purpose of the change** This PR fixes an order-dependent (OD) nondeterministic test in: ``` org.apache.shenyu.protocol.grpc.message.JsonMessageTest ``` The polluter is `testParseOfDynamicMessageMarshaller`, and the victim is `testCreateJsonMarshallerMethodDescriptor`. The OD failure happens only when the polluter runs before the victim. `JsonMessage.createJsonMarshallerMethodDescriptor()` uses a static cache (METHOD_DESCRIPTOR_CACHE) with a key constructed as: ``` serviceName + GrpcConstants.GRPC_JSON_SERVICE + methodName ``` This key does not include the MethodDescriptor.MethodType. Because of this, the polluter inserts a MethodDescriptor with type ```BIDI_STREAMING``` into the cache. When the victim runs afterward, it calls the same method but expects a ```UNARY``` descriptor. However, the method reads from the cache and receives the polluter’s descriptor, causing the victim to fail. --- ### **The Fix** A reflection-based cache clear is added at the beginning of: `testCreateJsonMarshallerMethodDescriptor` This ensures each test executes with clean state, eliminating order dependence and restoring determinism. <!-- Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request. --> --- 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. - [x] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`. -- 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]
