huangguangshan opened a new pull request, #779:
URL: https://github.com/apache/skywalking-java/pull/779
Fix plugin activation failure when witness class
`GatewayAutoConfiguration$1` does not exist in Spring Cloud Gateway 2.0.x
- [x] Add a unit test to verify that the fix works.
- [x] Explain briefly why the bug exists and how to fix it.
The current implementation of `AbstractGateway200EnhancePluginDefineV2` uses
`org.springframework.cloud.gateway.config.GatewayAutoConfiguration$1`
as a witness class:
```java
@Override
protected String[] witnessClasses() {
return new String[] {
"org.springframework.cloud.gateway.config.GatewayAutoConfiguration$1" };
}
However, in Spring Cloud Gateway 2.0.x, the anonymous inner class $1 does
not exist in the bytecode.
This causes the SkyWalking agent to report:
xxx Witness class
org.springframework.cloud.gateway.config.GatewayAutoConfiguration$1 does not
exist.
and the plugin fails to activate.
Solution
Use a stable, existing class (GatewayAutoConfiguration) as the witness class:
@Override
protected String[] witnessClasses() {
return new String[] {
"org.springframework.cloud.gateway.config.GatewayAutoConfiguration"
};
}
This class exists in all Spring Cloud Gateway 2.0.x versions, so the plugin
loads normally.
Added entry in CHANGES.md:
* Fix: Gateway plugin fails to load because witness class
GatewayAutoConfiguration$1 does
--
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]