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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
