You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "upangka (via GitHub)" <gi...@apache.org> on 2025/04/09 02:38:02 UTC
[I] [Bug] unable to deserialize Record using Fastjson2 [dubbo]
upangka opened a new issue, #15303:
URL: https://github.com/apache/dubbo/issues/15303
### Pre-check
- [x] I am sure that all the content I provide is in English.
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.
### Apache Dubbo Component
Java SDK (apache/dubbo)
### Dubbo Version
1. Dubbo Java 3.3.4
2. JDK 17
3. Win11
### Steps to reproduce this issue
> Fastjson2 Serialization Issue with Record Types in Dubbo 3.3.4
# Environment:
1.Spring Boot 3.3.10
2. Dubbo Java 3.3.4
3. fastjson2 2.0.57
4. JDK 17
# Problem Description
I'm encountering serialization issues when using fastjson2 as the serialization protocol between two Dubbo services (TestService and BFFService) with Java record types.
# Configuration
Both services include fastjson2 dependency:
```xml
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.57</version>
</dependency>
```
## TestService (Provider)
1. application.yml:
```yml
dubbo:
application:
name: shop-test-service
qos-enable: false
check-serializable: false
protocol:
port: 50556
name: tri
# serialization: hessian2
serialization: fastjson2
```
2. Service Interface:
```java
public interface TestService {
TestResponse testDeserialize(TestRequest request);
}
@DubboService
public class TestServiceImpl implements TestService {
@Override
public TestResponse testDeserialize(TestRequest request) {
List<Student> students = request.ids().stream()
.map(id -> new Student(id, UUID.randomUUID().toString()))
.toList();
return new TestResponse(students);
}
}
```
3. Record Types
```java
public record TestRequest(List<String> ids) implements Serializable {}
public record TestResponse(List<Student> students) implements Serializable {}
public record Student(String id, String name) implements Serializable {}
```
## BFFService (Consumer)
1. application.yml
```yml
dubbo:
application:
name: bff-service-consumer
qos-enable: false
protocol:
name: tri
# serialization: hessian2
serialization: fastjson2
```
2. Service Call
```java
@SpringBootApplication
@EnableDubbo
public class BFFApplication implements CommandLineRunner {
@DubboReference
TestService testService;
@Override
public void run(String... args) {
testService.testDeserialize(new TestRequest(List.of("123", "456")));
}
}
```
# Error Logs
> TestService Error:
```bash
org.apache.dubbo.remoting.http12.exception.DecodeException: Internal Server Error
Caused by: com.alibaba.fastjson2.JSONException: array not support input TYPED_ANY -110 ["123","456"], offset 45/94
```
> BFFService Error:
```bash
java.io.IOException: org.apache.dubbo.common.serialize.SerializationException:
[Serialization Security] Serialized class org.apache.dubbo.remoting.http12.exception.DecodeException is not in allow list.
Current mode is `STRICT`, will disallow to deserialize it by default.
Please add it into security/serialize.allowlist or follow FAQ to configure it.
```
### What you expected to happen
Fastjson2 should properly support Java Record serialization/deserialization, just like it works with regular classes
The behavior should match Hessian2's current working implementation (fixed in #14820)
### Anything else
Title: Fastjson2 Serialization Still Doesn't Support Record Types While Hessian2 Fix Already Implemented [#14820](https://github.com/apache/dubbo/pull/14820)
Related Issue: [#14820 (Fix unable to deserialize Record using Hessian2)](https://github.com/apache/dubbo/pull/14820)
Switching from fastjson2 to hessian2 serialization works without issues
### Are you willing to submit a pull request to fix on your own?
- [ ] Yes I am willing to submit a pull request on my own!
### 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@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
Re: [I] [Bug] unable to deserialize Record using Fastjson2 [dubbo]
Posted by "heliang666s (via GitHub)" <gi...@apache.org>.
heliang666s commented on issue #15303:
URL: https://github.com/apache/dubbo/issues/15303#issuecomment-2812085828
Thanks for your feedback, but this seems to be an issue with Fastjson. I suggest you open an issue in their community.@upangka
--
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
Re: [I] [Bug] unable to deserialize Record using Fastjson2 [dubbo]
Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw closed issue #15303: [Bug] unable to deserialize Record using Fastjson2
URL: https://github.com/apache/dubbo/issues/15303
--
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