Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

服务端从2.5.8升级到2.7.3后,客户端使用老版本调用服务端,Version.getIntVersion报错,响应失败 #5396

Closed
2 tasks
penghcn opened this issue Nov 28, 2019 · 5 comments

Comments

@penghcn
Copy link

penghcn commented Nov 28, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.3
  • Operating System version: macOS 10.15.1、任意Linux发行版
  • Java version: 1.8

参考#3784,Version.parseInt未再判断字符串的合法性,也未做异常处理

该bug还未修复。version从文件名获取,当文件名是dubbo-client.jar,解析得到version = "client" 时,isSupportResponseAttachment(Version.java:102) 中的代码块
if (StringUtils.isEmpty(version)) {
return false;
}
就失效了。
后续Version.parseInt未再判断字符串的合法性,也未做异常处理。
也就是会报错如下:
11/28 15:03:45.504 WARN org.apache.dubbo.remoting.exchange.codec.ExchangeCodec [NettyServerWorker-6-7] [DUBBO] Fail to encode response: Response [id=0, version=client, status=20, event=false, error=null, result=AppResponse [value=cn.pengh.core.rpc.RpcResponse@49995603, exception=null]], send bad_response info instead, cause: For input string: "", dubbo version: 2.7.3, current host: 192.168.6.46
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_201]
at java.lang.Integer.parseInt(Integer.java:592) ~[?:1.8.0_201]
at java.lang.Integer.parseInt(Integer.java:615) ~[?:1.8.0_201]
at org.apache.dubbo.common.Version.parseInt(Version.java:133) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.common.Version.getIntVersion(Version.java:118) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.common.Version.isSupportResponseAttachment(Version.java:102) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.rpc.protocol.dubbo.DubboCodec.encodeResponseData(DubboCodec.java:195) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeResponse(ExchangeCodec.java:283) [dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:71) [dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40) [dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70) [dubbo-2.7.3.jar:2.7.3]
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:716) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:708) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:791) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:701) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:303) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:716) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:708) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:791) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:701) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:115) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at org.apache.dubbo.remoting.transport.netty4.NettyServerHandler.write(NettyServerHandler.java:103) [dubbo-2.7.3.jar:2.7.3]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:716) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:708) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$1700(AbstractChannelHandlerContext.java:56) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:1102) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:1149) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:1073) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.43.Final.jar:4.1.43.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]

@penghcn
Copy link
Author

penghcn commented Nov 28, 2019

客户端依赖的jar包文件名是dubbo-client.jar ,里面的pom文件版本写的是0.0.1-SNAPSHOT的时候。
把文件名dubbo-client.jar 改成 dubbo-client-0.0.1-SNAPSHOT.jar 也是可以正常使用的

@penghcn
Copy link
Author

penghcn commented Nov 28, 2019

客户端文件名是dubbo-client.jar ,解析到的版本号是client

@chickenlj
Copy link
Contributor

#4488
The compatibility code has been added to v2.6.7 and the latest v2.7.4.1.

@chickenlj
Copy link
Contributor

for versions before 2.7.3, it only considers versions with the following format as legal:

  1. versions only contain consist of digital numbers, 2.0.0
  2. versions with string suffix like "2.6.7-stable" "0.0.1-SNAPSHOT".

Notice that if you are using Dubbo before v2.6.2, the version value is the same as the jar version.

@penghcn
Copy link
Author

penghcn commented Dec 4, 2019

好的,多谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants