Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix generic invoke retries bug #608

Merged
merged 2 commits into from May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,6 +43,10 @@ public class ConsumerGenericFilter extends Filter {
*/
private static final String METHOD_GENERIC_INVOKE = "$genericInvoke";

private final static String REVISE_KEY = "generic.revise";

private final static String REVISE_VALUE = "true";

/**
* 是否自动加载
*
Expand All @@ -58,6 +62,12 @@ public boolean needToLoad(FilterInvoker invoker) {
@Override
public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException {
try {

final String revised = (String) request.getRequestProp(REVISE_KEY);
//if has revised, invoke directly
if (REVISE_VALUE.equals(revised)) {
return invoker.invoke(request);
}
String type = getSerializeFactoryType(request.getMethodName(), request.getMethodArgs());
request.addRequestProp(RemotingConstants.HEAD_GENERIC_TYPE, type);

Expand All @@ -83,7 +93,7 @@ public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws So
String invokeType = consumerConfig.getMethodInvokeType(methodName);
request.setInvokeType(invokeType);
request.addRequestProp(RemotingConstants.HEAD_INVOKE_TYPE, invokeType);

request.addRequestProp(REVISE_KEY, REVISE_VALUE);
return invoker.invoke(request);
} catch (SofaRpcException e) {
throw e;
Expand Down
Expand Up @@ -16,6 +16,9 @@
*/
package com.alipay.sofa.rpc.test.generic;

import java.util.ArrayList;
import java.util.List;

import com.alipay.hessian.generic.model.GenericArray;
import com.alipay.hessian.generic.model.GenericCollection;
import com.alipay.hessian.generic.model.GenericMap;
Expand All @@ -39,9 +42,6 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
Expand Down Expand Up @@ -69,6 +69,9 @@ public void testAll() throws SofaRpcException, InterruptedException {
MethodConfig config3 = new MethodConfig().setName("helloOneway")
.setInvokeType("oneway");
methodConfigs.add(config3);
MethodConfig config4 = new MethodConfig().setName("helloTimeout")
.setInvokeType("sync");
methodConfigs.add(config4);

// C服务的服务端
ProviderConfig<TestInterface> CProvider = new ProviderConfig<TestInterface>()
Expand All @@ -83,7 +86,8 @@ public void testAll() throws SofaRpcException, InterruptedException {
.setGeneric(true)
.setMethods(methodConfigs)
.setDirectUrl("bolt://127.0.0.1:22222")
.setTimeout(3000);
.setTimeout(3000)
.setRetries(2);
GenericService proxy = BConsumer.refer();

GenericObject genericObject = new GenericObject(
Expand Down