dangdangdotcom / dubbox

Dubbox now means Dubbo eXtensions, and it adds features like RESTful remoting, Kyro/FST serialization, etc to the Dubbo service framework.
http://dangdangdotcom.github.io/dubbox
Apache License 2.0
4.89k stars 2.06k forks source link

dubbox 服务异常:java.io.IOException: com.esotericsoftware.kryo.KryoException: Buffer underflow #332

Open jiangyilong opened 7 years ago

jiangyilong commented 7 years ago

调用服务的时候报了下面的错误。没看明白是什么原因造成的。

com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getCustomerCard in the service com.yiguo.qiakr.customer.service.CustomerCardDubboService. Tried 3 times of the providers [10.4.27.216:18602] (1/1) from the registry 127.0.0.1:2181 on the consumer 10.4.30.207 using the dubbo version 2.8.4. Last error is: Failed to invoke remote method: getCustomerCard, provider: dubbo://10.4.27.216:18602/com.yiguo.qiakr.customer.service.CustomerCardDubboService?anyhost=true&application=qiakr-merchant&check=false&connections=20&dubbo=2.8.4&generic=false&group=annotationConfig&interface=com.yiguo.qiakr.customer.service.CustomerCardDubboService&methods=clearCustomerCard,getCustomerCardById,updateMobile,generatePersonCode,getCustomerCardByPhone,countCustomerCardByCustomerIdList,updateCustomerCardCreateDate,updateCustomerCard,updateCustomerExtCardNo,getCustomerCard,getAllCustomerCardVoListByUnionId,getActiveCustomerIdList,resetCustomerExtCardNo,createCustomerCard,updateMobileAndVerifyCode,isCreateCustomerCard,deleteByCustomerIdAndSupplierId,insertCustomerCard&monitor=dubbo%3A%2F%2F127.0.0.1%3A2181%2Fcom.alibaba.dubbo.registry.RegistryService%3Fapplication%3Dqiakr-merchant%26dubbo%3D2.8.4%26pid%3D14117%26protocol%3Dregistry%26refer%3Ddubbo%253D2.8.4%2526interface%253Dcom.alibaba.dubbo.monitor.MonitorService%2526pid%253D14117%2526timestamp%253D1498098857236%26registry%3Dzookeeper%26timestamp%3D1498098857236&organization=dubbox&owner=programmer&pid=14117&protocol=dubbo&revision=1.3.0-SNAPSHOT&serialization=kryo&side=consumer&timeout=2000&timestamp=1498098857222&validation=true&version=1.0, cause: java.io.IOException: com.esotericsoftware.kryo.KryoException: Buffer underflow. Serialization trace: supplierId (com.yiguo.qiakr.customer.obj.CustomerCard) java.io.IOException: com.esotericsoftware.kryo.KryoException: Buffer underflow. Serialization trace: supplierId (com.yiguo.qiakr.customer.obj.CustomerCard) at com.alibaba.dubbo.common.serialize.support.kryo.KryoObjectInput.readObject(KryoObjectInput.java:127) at com.alibaba.dubbo.common.serialize.support.kryo.KryoObjectInput.readObject(KryoObjectInput.java:140) at com.alibaba.dubbo.common.serialize.support.kryo.KryoObjectInput.readObject(KryoObjectInput.java:151) at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:87) at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:117) at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.decodeBody(DubboCodec.java:98) at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:134) at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:95) at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.decode(DubboCountCodec.java:46) at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalDecoder.messageReceived(NettyCodecAdapter.java:134) at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.esotericsoftware.kryo.KryoException: Buffer underflow. Serialization trace: supplierId (com.yiguo.qiakr.customer.obj.CustomerCard) at com.esotericsoftware.kryo.io.Input.require(Input.java:181) at com.esotericsoftware.kryo.io.Input.readVarLong(Input.java:690) at com.esotericsoftware.kryo.io.Input.readLong(Input.java:685) at com.esotericsoftware.kryo.serializers.DefaultSerializers$LongSerializer.read(DefaultSerializers.java:133) at com.esotericsoftware.kryo.serializers.DefaultSerializers$LongSerializer.read(DefaultSerializers.java:123) at com.esotericsoftware.kryo.Kryo.readObjectOrNull(Kryo.java:730) at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:113) at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:528) at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:761) at com.alibaba.dubbo.common.serialize.support.kryo.KryoObjectInput.readObject(KryoObjectInput.java:125) ... 24 more

    at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:108)

: at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227) at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72) at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52) at com.alibaba.dubbo.common.bytecode.proxy9.getCustomerCard(proxy9.java) at yike.service.CustomerOrderService.getOrderVoList(CustomerOrderService.java:1823) at yike.service.CustomerOrderService$$FastClassBySpringCGLIB$$45e15f42.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:42) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:42) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) at yike.service.CustomerOrderService$$EnhancerBySpringCGLIB$$51738431.getOrderVoList() at yike.service.QiakrConsumerService.homepageGuidePop(QiakrConsumerService.java:529) at yike.service.QiakrConsumerService$$FastClassBySpringCGLIB$$e16140c.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:42) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) :

yangl commented 7 years ago

返回值超过4096字节了吧,https://github.com/dangdangdotcom/dubbox/blob/master/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectOutput.java#L35 这个 /* Creates a new Output for writing to an OutputStream. A buffer size of 4096 is used. / public Output (OutputStream outputStream) { this(4096, 4096); if (outputStream == null) throw new IllegalArgumentException("outputStream cannot be null."); this.outputStream = outputStream; }

kimmking commented 7 years ago

配置url里加上body=一个个足够大的数