xzyJavaX opened a new issue, #9258: URL: https://github.com/apache/skywalking/issues/9258
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues. ### Apache SkyWalking Component Java Agent (apache/skywalking-java) ### What happened When using org.elasticsearch.client:elasticsearch-rest-high-level-client:6.3.0, elasticsearch-6.x-plugin throws NPE. Error log: ``` ERROR 2022-06-21 18:05:45.958 pool-9-thread-2 InstMethodsInter : class[class org.elasticsearch.client.RestHighLevelClient] before method[get] intercept failure java.lang.NullPointerException at org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.RestHighLevelClientGetMethodsInterceptor.beforeMethod(RestHighLevelClientGetMethodsInterceptor.java:44) at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:76) at org.elasticsearch.client.RestHighLevelClient.get(RestHighLevelClient.java) ``` Supported-list.md shows that the elasticsearch-rest-high-level-client only supports 6.7.1-6.8.4, while the current version is 6.3.0, but it should not have been enhanced. We found that there is a problem selecting withess classes in `org.apache.skywalking.apm.plugin.elasticsearch.v6.define.RestHighLevelClientInstrumentation` in elasticsearch-6.x-plugin.The current selected withess class is `org.elasticsearch.transport.TaskTransportChannel`, and `org.elasticsearch.transport.TaskTransportChannel` also exists in elasticsearch:6.3.0, so it has been incorrectly enhanced. In the interceptor for `org.elasticsearch.client.RestHighLevelClient` constructor, `getNodes()` will be called: ``` List<org.elasticsearch.client.Node> nodeList = restClient.getNodes(); ``` Both `org.elasticsearch.client.Node` and `org.elasticsearch.client.RestClient#getNodes()` are introduced in the elasticsearch:6.4.0, this will cause exceptions, as a result, subsequent `objInst.setSkyWalkingDynamicField(restClientEnhanceInfo)` is not called successfully, when other methods of `org.elasticsearch.client.RestHighLevelClient` are called later, `objInst.getSkyWalkingDynamicField()` returns null and then causes NPE. ### What you expected to happen When using org.elasticsearch.client:elasticsearch-rest-high-level-client:6.3.0, `org.elasticsearch.client.RestHighLevelClient` should not be enhanced, avoid throw NPE. We may use `org.elasticsearch.client.indices.CreateIndexResponse` as the witness class. This class was introduced in elasticsearch:6.7.0, also can change the supported version to 6.7.0-6.8.4. ### How to reproduce Use org.elasticsearch.client:elasticsearch-rest-high-level-client:6.3.x and mount skywalking-agent. Create an object of `org.elasticsearch.client.RestHighLevelClient` and call its `get` method. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
