feat: generic timeout (#11677)

* feat: generic timeout

* feat: generic timeout

* feat: fix ut

* feat: change to default

* feat: test verify method

* feat: test verify method

* Update dubbo-common/src/test/java/org/apache/dubbo/config/AbstractInterfaceConfigTest.java

change to assertFalse

Co-authored-by: Albumen Kevin <jhq0812@gmail.com>

* Update dubbo-common/src/test/java/org/apache/dubbo/config/AbstractInterfaceConfigTest.java

assertFalse

Co-authored-by: Albumen Kevin <jhq0812@gmail.com>

* feat: fix ut。。。

* feat: fix ut。。。

* feat: testVerifyMethod

* feat: testVerifyMethod

* feat: fix msg

---------

Co-authored-by: Albumen Kevin <jhq0812@gmail.com>
This commit is contained in:
aamingaa 2023-04-11 14:20:48 +08:00 committed by GitHub
parent ffb28bc85e
commit 93d146924a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 5 deletions

View File

@ -374,7 +374,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
}
private boolean verifyMethodConfig(MethodConfig methodConfig, Class<?> interfaceClass, boolean ignoreInvalidMethodConfig) {
protected boolean verifyMethodConfig(MethodConfig methodConfig, Class<?> interfaceClass, boolean ignoreInvalidMethodConfig) {
String methodName = methodConfig.getName();
if (StringUtils.isEmpty(methodName)) {
String msg = "<dubbo:method> name attribute is required! Please check: " +
@ -396,7 +396,12 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
return false;
} else {
throw new IllegalStateException(msg);
if (!isNeedCheckMethod()) {
msg = "Generic call: " + msg;
logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
} else {
throw new IllegalStateException(msg);
}
}
}
return true;
@ -413,6 +418,11 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
return null;
}
@Transient
protected boolean isNeedCheckMethod() {
return true;
}
private boolean hasArgumentConfigProps(Map<String, String> configProperties, String methodName, int argIndex) {
String argPrefix = methodName + "." + argIndex + ".";
return ConfigurationUtils.hasSubProperties(configProperties, argPrefix);

View File

@ -183,6 +183,11 @@ public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig {
}
}
@Override
protected boolean isNeedCheckMethod() {
return StringUtils.isEmpty(getGeneric());
}
/**
* @return
* @deprecated instead, use the parameter <b>scope</> to judge if it's in jvm, scope=local

View File

@ -18,7 +18,6 @@ package org.apache.dubbo.config;
import org.apache.dubbo.common.constants.CommonConstants;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@ -236,7 +235,28 @@ class AbstractInterfaceConfigTest {
Assertions.assertEquals("scope", interfaceConfig.getScope());
}
@Test
void testVerifyMethod() {
InterfaceConfig2 interfaceConfig2 = new InterfaceConfig2();
MethodConfig methodConfig = new MethodConfig();
methodConfig.setTimeout(5000);
methodConfig.setName("sayHello");
Class<?> clazz = Greeting.class;
boolean verifyResult = interfaceConfig2.verifyMethodConfig(methodConfig, clazz, false);
Assertions.assertTrue(verifyResult);
boolean verifyResult2 = interfaceConfig2.verifyMethodConfig(methodConfig, clazz, true);
Assertions.assertFalse(verifyResult2);
}
public static class InterfaceConfig2 extends AbstractInterfaceConfig {
@Override
protected boolean isNeedCheckMethod() {
return false;
}
}
public static class InterfaceConfig extends AbstractInterfaceConfig {
}
}
}

View File

@ -476,4 +476,4 @@ class MethodConfigTest {
Map<String, String> metaData = methodConfig.getMetaData();
Assertions.assertEquals(0, metaData.size(), "Expect empty metadata but found: "+metaData);
}
}
}