You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "natsumm (via GitHub)" <gi...@apache.org> on 2023/02/02 02:32:58 UTC
[GitHub] [dubbo] natsumm opened a new issue, #11442: provider泛型类型为Float时返回Double类型
natsumm opened a new issue, #11442:
URL: https://github.com/apache/dubbo/issues/11442
<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
- [X] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
### Environment
* Dubbo version: 3.0.7
* Operating System version: Linux Ubuntu-20.04
* Java version: 1.8
### Steps to reproduce this issue
1. provider返回泛型为Float
2. consumer以Float接收返回参数
Demo地址: https://github.com/natsumm/dubbo-generic-float-issue
### Expected Behavior
<!-- What do you expect from the above steps?-->
返回Float类型参数
### Actual Behavior
<!-- What actually happens? -->
返回了Double类型参数,并抛出java.lang.ClassCastException
### Detail
1. provider端代码
```
@DubboService
public class DemoServiceImpl implements DemoService {
@Override
public String sayHello(String name) {
return "Hello " + name;
}
//此处定义为Float类型
@Override
public List<Float> getFloats() {
List<Float> floats = new ArrayList<>();
floats.add(35.3F);
floats.add(45.1F);
return floats;
}
}
```
2. consumer端代码
```
@SpringBootApplication
@Service
@EnableDubbo
public class ConsumerApplication {
@DubboReference
private DemoService demoService;
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(ConsumerApplication.class, args);
ConsumerApplication application = context.getBean(ConsumerApplication.class);
String result = application.doSayHello("world");
System.out.println("result: " + result);
//此处返回了Double类型
List<Float> floats = application.getFloats();
System.out.println("floats = " + floats);
Float aFloat = floats.get(0);
}
public String doSayHello(String name) {
return demoService.sayHello(name);
}
public List<Float> getFloats() {
return demoService.getFloats();
}
}
```
3. 预期返回Float类型实际Double

--
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@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] mytang0 commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "mytang0 (via GitHub)" <gi...@apache.org>.
mytang0 commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1413333759
> However, when I used other serialization protocols(like `kryo` and `sft`), it still returned **Double** type except `nativejava`.
Thank you for your feedback. Let's wait for the fix.
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] natsumm commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "natsumm (via GitHub)" <gi...@apache.org>.
natsumm commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1413426726
> Thank you for your feedback. Let's wait for the fix.
Ok, thank you for the reply.
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] natsumm commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "natsumm (via GitHub)" <gi...@apache.org>.
natsumm commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1413065823
经验证,dubbo 3.0.0~3.1.5均存在此问题
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] KamToHung commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "KamToHung (via GitHub)" <gi...@apache.org>.
KamToHung commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1413793771
I try to use fastjson2, kryo and sft that it return float.
I think the problem is hessian serialization.
org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcResult#handleValue
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] natsumm closed issue #11442: provider泛型类型为Float时返回Double类型
Posted by "natsumm (via GitHub)" <gi...@apache.org>.
natsumm closed issue #11442: provider泛型类型为Float时返回Double类型
URL: https://github.com/apache/dubbo/issues/11442
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] natsumm commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "natsumm (via GitHub)" <gi...@apache.org>.
natsumm commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1514033893
> 我目前是这么处理的 dubbo.version = 3.1.5
>
> # 1 application.yml
> ```yaml
> dubbo:
> protocols:
> dubbo:
> name: dubbo
> serialization: fst
> ```
>
> # 2 pom.xml
> ```
> <dependency>
> <groupId>org.apache.dubbo</groupId>
> <artifactId>dubbo-serialization-fst</artifactId>
> </dependency>
> ```
使用`fst`插件的版本为 2.7.22
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] natsumm commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "natsumm (via GitHub)" <gi...@apache.org>.
natsumm commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1514032846
我目前是这么处理的
dubbo.version = 3.1.5
# 1 application.yml
```yaml
dubbo:
protocols:
dubbo:
name: dubbo
serialization: fst
```
# 2 pom.xml
```xml
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-fst</artifactId>
</dependency>
```
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] mytang0 commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "mytang0 (via GitHub)" <gi...@apache.org>.
mytang0 commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1413257155
Yes, the problem is caused by serialization of float by hessian.
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] natsumm commented on issue #11442: provider泛型类型为Float时返回Double类型
Posted by "natsumm (via GitHub)" <gi...@apache.org>.
natsumm commented on issue #11442:
URL: https://github.com/apache/dubbo/issues/11442#issuecomment-1413276952
However, when I used other serialization protocols(like `kryo` and `sft`), it still returned **Double** type except `nativejava`.
--
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@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org