You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.7
Operating System version: xxx
Java version: 1.8
Steps to reproduce this issue
create a REST controller with a param which type is org.springframework.data.domain.Pageable
`import com.example.dubbo.provider.DemoService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DemoController { @reference(version = "1.0.0", url = "dubbo://127.0.0.1:12345")
private DemoService demoService;
export com.example.dubbo.provider.DemoServiceImpl#sayHello service with dubbo protocol on 12345 port
`import org.apache.dubbo.config.annotation.Service;
import org.springframework.data.domain.Pageable;
@service(version = "1.0.0")
public class DemoServiceImpl implements DemoService { @OverRide
public void sayHello(Pageable pageable) {
System.out.println(String.format("pageable: page=%d, size=%d", pageable.getPageNumber(), pageable.getPageNumber()));
}
}`
call http://localhost:8080/sayHello with no params, on the provider side, we get an exception indicate 'org.springframework.data.domain.PageRequest' could not be instantiated.
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
We expect in the com.example.dubbo.provider.DemoServiceImpl#sayHello method, the param can be initial correctly, in this case, it should print "page=0, size=20" successfully,which is the default value of an instance of PageRequest class.
Actual Result
On the provider side ,we get an exception indicate that can NOT initial an instance of rg.springframework.data.domain.PageRequest class.
2020-08-11 16:00:14.159 WARN 229668 --- [:12345-thread-2] o.a.d.r.p.dubbo.DecodeableRpcInvocation : [DUBBO] Decode argument failed: 'org.springframework.data.domain.PageRequest' could not be instantiated, dubbo version: 2.7.7, current host: 160.12.11.53
com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'org.springframework.data.domain.PageRequest' could not be instantiated
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.instantiate(JavaDeserializer.java:317) ~[dubbo-2.7.7.jar:2.7.7]
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:202) ~[dubbo-2.7.7.jar:2.7.7]
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2848) ~[dubbo-2.7.7.jar:2.7.7]
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2175) ~[dubbo-2.7.7.jar:2.7.7]
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2104) ~[dubbo-2.7.7.jar:2.7.7]
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2148) ~[dubbo-2.7.7.jar:2.7.7]
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2104) ~[dubbo-2.7.7.jar:2.7.7]
at org.apache.dubbo.common.serialize.hessian2.Hessian2ObjectInput.readObject(Hessian2ObjectInput.java:100) ~[dubbo-2.7.7.jar:2.7.7]
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:143) [dubbo-2.7.7.jar:2.7.7]
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:80) [dubbo-2.7.7.jar:2.7.7]
at org.apache.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:57) [dubbo-2.7.7.jar:2.7.7]
at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:44) [dubbo-2.7.7.jar:2.7.7]
at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57) [dubbo-2.7.7.jar:2.7.7]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_112]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_112]
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_112]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_112]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_112]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_112]
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.instantiate(JavaDeserializer.java:313) ~[dubbo-2.7.7.jar:2.7.7]
... 15 common frames omitted
Caused by: java.lang.IllegalArgumentException: Page size must not be less than one!
at org.springframework.data.domain.AbstractPageRequest.<init>(AbstractPageRequest.java:50) ~[spring-data-commons-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.data.domain.PageRequest.<init>(PageRequest.java:43) ~[spring-data-commons-2.3.2.RELEASE.jar:2.3.2.RELEASE]
... 20 common frames omitted
After debugged on this, we founded when deserializing params using hessian (which is the default serialize method using by dubbo protocol), the size field which is int type in PageRequest class was initialled to 0, but the constructor of org.springframework.data.domain.PageRequest can not permit this field less than one.
Why hessian can not call the constructor with values of the params received from the consumer side, instead of with initial values?
The text was updated successfully, but these errors were encountered:
Environment
Steps to reproduce this issue
`import com.example.dubbo.provider.DemoService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DemoController {
@reference(version = "1.0.0", url = "dubbo://127.0.0.1:12345")
private DemoService demoService;
}`
`import org.apache.dubbo.config.annotation.Service;
import org.springframework.data.domain.Pageable;
@service(version = "1.0.0")
public class DemoServiceImpl implements DemoService {
@OverRide
public void sayHello(Pageable pageable) {
System.out.println(String.format("pageable: page=%d, size=%d", pageable.getPageNumber(), pageable.getPageNumber()));
}
}`
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
We expect in the com.example.dubbo.provider.DemoServiceImpl#sayHello method, the param can be initial correctly, in this case, it should print "page=0, size=20" successfully,which is the default value of an instance of PageRequest class.
Actual Result
On the provider side ,we get an exception indicate that can NOT initial an instance of rg.springframework.data.domain.PageRequest class.
After debugged on this, we founded when deserializing params using hessian (which is the default serialize method using by dubbo protocol), the size field which is int type in PageRequest class was initialled to 0, but the constructor of org.springframework.data.domain.PageRequest can not permit this field less than one.
Why hessian can not call the constructor with values of the params received from the consumer side, instead of with initial values?
The text was updated successfully, but these errors were encountered: