fix timeout type cast exception (#10644)
Signed-off-by: crazyhzm <crazyhzm@gmail.com> Signed-off-by: crazyhzm <crazyhzm@gmail.com>
This commit is contained in:
parent
89ef73d023
commit
37b205bd11
|
|
@ -259,8 +259,17 @@ public class RpcUtils {
|
|||
return timeout;
|
||||
}
|
||||
|
||||
public static long getTimeoutFromInvocation(Invocation invocation, long defaultTimeout) {
|
||||
long timeout = defaultTimeout;
|
||||
Object genericTimeout = invocation.getObjectAttachment(TIMEOUT_KEY);
|
||||
if (genericTimeout != null) {
|
||||
timeout = convertToNumber(genericTimeout, defaultTimeout);
|
||||
}
|
||||
return timeout;
|
||||
}
|
||||
|
||||
private static long convertToNumber(Object obj, long defaultTimeout) {
|
||||
long timeout = 0;
|
||||
long timeout = defaultTimeout;
|
||||
try {
|
||||
if (obj instanceof String) {
|
||||
timeout = Long.parseLong((String) obj);
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
|
|||
|
||||
private int calculateTimeout(Invocation invocation, String methodName) {
|
||||
if (invocation.getObjectAttachment(TIMEOUT_KEY) != null) {
|
||||
return (int) invocation.getObjectAttachment(TIMEOUT_KEY);
|
||||
return (int) RpcUtils.getTimeoutFromInvocation(invocation, 3000);
|
||||
}
|
||||
Object countdown = RpcContext.getClientAttachment().getObjectAttachment(TIME_COUNTDOWN_KEY);
|
||||
int timeout;
|
||||
|
|
|
|||
Loading…
Reference in New Issue