You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/11/08 11:00:19 UTC

[GitHub] [skywalking] zjutkz opened a new issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

zjutkz opened a new issue #8091:
URL: https://github.com/apache/skywalking/issues/8091


   ### 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
   
   AsyncHttpClient version: 2.0.33
   ```
   <dependency>
         <groupId>org.asynchttpclient</groupId>
         <artifactId>async-http-client</artifactId>
         <version>2.0.33</version>
   </dependency>
   ```
   
   Skywalking JavaAgent version: 8.6.0
   
   When I use AsyncHttpClient in my code, NoSuchMethodError occurs in my promgram. My code:
   `    private static final AsyncHttpClient ASYNC_HTTP_CLIENT;
       private static final int MAX_CONNECTION = 100000;
   
       static {
           DefaultAsyncHttpClientConfig.Builder configBuilder = new DefaultAsyncHttpClientConfig.Builder();
           configBuilder.setMaxConnections(MAX_CONNECTION);
           configBuilder.setMaxConnectionsPerHost(10000);
           configBuilder.setReadTimeout(3000);
           configBuilder.setRequestTimeout(10000);
           configBuilder.setConnectTimeout(1000);
           configBuilder.setDisableUrlEncodingForBoundRequests(true);
           configBuilder.setThreadPoolName("lika-async-http");
           if (Epoll.isAvailable()) {
               configBuilder.setUseNativeTransport(true);
           }
           configBuilder.setMaxRequestRetry(3);
           configBuilder.setKeepAlive(true);
           configBuilder.setTcpNoDelay(true);
           DefaultAsyncHttpClientConfig cf = configBuilder.build();
           ASYNC_HTTP_CLIENT = new DefaultAsyncHttpClient(cf);
       }
   
       public static void main(String[] args) {
           BoundRequestBuilder builder = ASYNC_HTTP_CLIENT.prepareGet("http://www.baidu.com");
           builder.execute(new AsyncCompletionHandler<Response>() {
               public Response onCompleted(Response response) throws Exception {
                   System.out.println(response.getStatusCode());
                   return null;
               }
   
               @Override
               public void onThrowable(Throwable t) {
                   t.printStackTrace();
               }
           });
       }
   
   Exception message:
   `java.lang.AbstractMethodError: org.apache.skywalking.apm.plugin.asynchttpclient.v2.AsyncHandlerWrapper.onHeadersReceived(Lorg/asynchttpclient/HttpResponseHeaders;)Lorg/asynchttpclient/AsyncHandler$State;
   	at org.asynchttpclient.netty.handler.HttpHandler.exitAfterHandlingHeaders(HttpHandler.java:101)
   	at org.asynchttpclient.netty.handler.HttpHandler.notifyHandler(HttpHandler.java:77)
   	at org.asynchttpclient.netty.handler.HttpHandler.handleHttpResponse(HttpHandler.java:133)
   	at org.asynchttpclient.netty.handler.HttpHandler.handleRead(HttpHandler.java:186)
   	at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:76)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335)
   	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335)
   	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335)
   	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)
   	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:312)
   	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:299)
   	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:415)
   	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
   	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335)
   	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356)
   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
   	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
   	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
   	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
   	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
   	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
   	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
   	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131)
   	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
   	at java.lang.Thread.run(Thread.java:748)`
   
   ### What you expected to happen
   
   This is an unexpected behaviour, Skywalking cannot affect the original behavior.
   
   ### How to reproduce
   
   Run the code I showed above.
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] 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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zjutkz commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
zjutkz commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963324330


   @wu-sheng Thanks for you reply, I know how wrapper works, I have been developing Android for the past 4 years, and there are lots of wrapper in Android, but Android has a very poor code compatibility, so I have to do a lot of compatibility works like write xxxWrapperV21, xxxWrapperV23. In this case,if I want to support 2.0.0 as you mentioned,I think I should write a class AsyncHandlerWrapperV20, this seems to mean that I need to find a balance between compatibility and workload.
   Another question is, as I mentioned before, there are lots of plugins used wrapper mode, do I need to do compatibility testing for each of these plugins? Because SkyWalking note that it support AsyncHttpClient 2.x but in fact it just support 2.1+, I am afraid this situation will appear on other plugins.
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng edited a comment on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
wu-sheng edited a comment on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963273204


   > The root cause of this problem is Skywalking changes the arguments of origin method like this
   
   This is not a root cause. 
   
   Wrapper is a very common way to do instrumentation. This is not dangerous at all. The point of this is this library changed APIs between `2.0` and `2.1+`, which is why our codes could pass compiling and tests, but your `2.0.10`(all 2.0.x I think) could report `AbstractMethodError` error. 


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963112523


   Read https://github.com/apache/skywalking-java/pull/68. The short version is, 2.0.x is not supported. 


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zjutkz commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
zjutkz commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963759484


   @wu-sheng Thanks again for your reply, I think I probably know what to do.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng closed issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #8091:
URL: https://github.com/apache/skywalking/issues/8091


   


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963275827


   Once SkyWalking needs to identify versions, it use witness classes or/and methods to avoid different methods/classes in various versions. But in your case, in this specific plugin, no one provides supports for `2.0.x`, so, you see this, and feel `dangerous`. 
   
   This is a daily case when you write a plugin for a library. The fix is not hard if you want to do. Read our plugin development document, and you could contribute a plugin(interceptor with witness instrumentation definition) to support 2.0.0, but 2.1+ still works automatically. This is what SkyWalking agent kernel is doing.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zjutkz commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
zjutkz commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963227892


   @wu-sheng 
   The root cause of this problem is Skywalking changes the arguments of origin method like this:
   `allArguments[1] = new AsyncHandlerWrapper((AsyncHandler) allArguments[1], span);`
   This is a very dangerous action because we cannot predict how the methods of these components will change in the higher version.And I found a lot of similar codes in Skywalking's Java plugin such as rabbitmq、kafka、grpc.
   This leads me to spend a lot of time to do version compatibility testing, so may I ask what was the original intention of doing this?


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963701471


   Codes in the open source community are contributed by world wide, we have set up the testing framework to verify the supported-versions statement. But every time human gets involved, everyone could make a mistake. This time, the code contributor didn't follow the testing framework requirements, and PR reviewers(including myself) missed this, so it didn't verify all declared versions. But this is also a normal case. Don't be surprised about mistake, bug or doc issue. This happens every day.
   
   I think your question doesn't make sense. No one should say for any code, **this doesn't need testing**.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8091: [Bug] AsyncHttpClient NoSuchMethodError

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8091:
URL: https://github.com/apache/skywalking/issues/8091#issuecomment-963273204


   Wrapper is a very common way to do instrumentation. This is not dangerous at all. The point of this is this library changed APIs between `2.0` and `2.1+`, which is why our codes could pass compiling and tests, but your `2.0.10`(all 2.0.x I think) could report `AbstractMethodError` error. 


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org