* fix hessian2 deserialize fail (#9533) * refactor: Delete redundant import items
This commit is contained in:
parent
3caab028bc
commit
e5f309a322
|
|
@ -19,10 +19,16 @@ package org.apache.dubbo.demo;
|
|||
import org.apache.dubbo.demo.hello.HelloReply;
|
||||
import org.apache.dubbo.demo.hello.HelloRequest;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface GreeterService {
|
||||
|
||||
/**
|
||||
* Sends a greeting
|
||||
*/
|
||||
HelloReply sayHello(HelloRequest request);
|
||||
|
||||
|
||||
CompletableFuture<String> sayHelloAsync(String request);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package org.apache.dubbo.demo;
|
|||
import org.apache.dubbo.demo.hello.HelloReply;
|
||||
import org.apache.dubbo.demo.hello.HelloRequest;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class GreeterServiceImpl implements GreeterService {
|
||||
|
||||
@Override
|
||||
|
|
@ -27,4 +29,9 @@ public class GreeterServiceImpl implements GreeterService {
|
|||
.setMessage("Hello " + request.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<String> sayHelloAsync(String name) {
|
||||
return CompletableFuture.supplyAsync(() -> name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.dubbo.demo.hello.HelloReply;
|
|||
import org.apache.dubbo.demo.hello.HelloRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ApiConsumer {
|
||||
|
|
@ -53,6 +54,9 @@ public class ApiConsumer {
|
|||
.build());
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
System.out.println("Reply: " + reply.getMessage());
|
||||
|
||||
CompletableFuture<String> sayHelloAsync = greeterService.sayHelloAsync("triple");
|
||||
System.out.println("Async Reply: "+sayHelloAsync.get());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dubbo.common.serialize;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.ClassUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -39,9 +38,8 @@ public class DefaultMultipleSerialization implements MultipleSerialization {
|
|||
public Object deserialize(URL url, String serializeType, String clz, InputStream os) throws IOException, ClassNotFoundException {
|
||||
serializeType = convertHessian(serializeType);
|
||||
final Serialization serialization = url.getOrDefaultFrameworkModel().getExtensionLoader(Serialization.class).getExtension(serializeType);
|
||||
final Class<?> aClass = ClassUtils.forName(clz);
|
||||
final ObjectInput in = serialization.deserialize(null, os);
|
||||
return in.readObject(aClass);
|
||||
return in.readObject();
|
||||
}
|
||||
|
||||
private String convertHessian(String ser) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue