* 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.HelloReply;
|
||||||
import org.apache.dubbo.demo.hello.HelloRequest;
|
import org.apache.dubbo.demo.hello.HelloRequest;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public interface GreeterService {
|
public interface GreeterService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a greeting
|
* Sends a greeting
|
||||||
*/
|
*/
|
||||||
HelloReply sayHello(HelloRequest request);
|
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.HelloReply;
|
||||||
import org.apache.dubbo.demo.hello.HelloRequest;
|
import org.apache.dubbo.demo.hello.HelloRequest;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class GreeterServiceImpl implements GreeterService {
|
public class GreeterServiceImpl implements GreeterService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -27,4 +29,9 @@ public class GreeterServiceImpl implements GreeterService {
|
||||||
.setMessage("Hello " + request.getName())
|
.setMessage("Hello " + request.getName())
|
||||||
.build();
|
.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 org.apache.dubbo.demo.hello.HelloRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ApiConsumer {
|
public class ApiConsumer {
|
||||||
|
|
@ -53,6 +54,9 @@ public class ApiConsumer {
|
||||||
.build());
|
.build());
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
System.out.println("Reply: " + reply.getMessage());
|
System.out.println("Reply: " + reply.getMessage());
|
||||||
|
|
||||||
|
CompletableFuture<String> sayHelloAsync = greeterService.sayHelloAsync("triple");
|
||||||
|
System.out.println("Async Reply: "+sayHelloAsync.get());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
package org.apache.dubbo.common.serialize;
|
package org.apache.dubbo.common.serialize;
|
||||||
|
|
||||||
import org.apache.dubbo.common.URL;
|
import org.apache.dubbo.common.URL;
|
||||||
import org.apache.dubbo.common.utils.ClassUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
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 {
|
public Object deserialize(URL url, String serializeType, String clz, InputStream os) throws IOException, ClassNotFoundException {
|
||||||
serializeType = convertHessian(serializeType);
|
serializeType = convertHessian(serializeType);
|
||||||
final Serialization serialization = url.getOrDefaultFrameworkModel().getExtensionLoader(Serialization.class).getExtension(serializeType);
|
final Serialization serialization = url.getOrDefaultFrameworkModel().getExtensionLoader(Serialization.class).getExtension(serializeType);
|
||||||
final Class<?> aClass = ClassUtils.forName(clz);
|
|
||||||
final ObjectInput in = serialization.deserialize(null, os);
|
final ObjectInput in = serialization.deserialize(null, os);
|
||||||
return in.readObject(aClass);
|
return in.readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String convertHessian(String ser) {
|
private String convertHessian(String ser) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue