|
|
|
@ -20,6 +20,7 @@ package com.tencent.cloud.polaris.circuitbreaker.resttemplate;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
|
|
import com.tencent.cloud.polaris.circuitbreaker.exception.FallbackWrapperException;
|
|
|
|
|
import com.tencent.polaris.api.pojo.CircuitBreakerStatus;
|
|
|
|
|
import com.tencent.polaris.circuitbreak.client.exception.CallAbortedException;
|
|
|
|
|
|
|
|
|
@ -63,6 +64,7 @@ public class PolarisCircuitBreakerRestTemplateInterceptor implements ClientHttpR
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
|
|
|
|
|
try {
|
|
|
|
|
return circuitBreakerFactory.create(request.getURI().getHost() + "#" + request.getURI().getPath()).run(
|
|
|
|
|
() -> {
|
|
|
|
|
try {
|
|
|
|
@ -93,9 +95,20 @@ public class PolarisCircuitBreakerRestTemplateInterceptor implements ClientHttpR
|
|
|
|
|
return new PolarisCircuitBreakerHttpResponse(fallbackInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new IllegalStateException(t);
|
|
|
|
|
throw new FallbackWrapperException(t);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
} catch (FallbackWrapperException e) {
|
|
|
|
|
Throwable underlyingException = e.getCause();
|
|
|
|
|
if (underlyingException instanceof IllegalStateException) {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
if (underlyingException instanceof RuntimeException) {
|
|
|
|
|
throw (RuntimeException) underlyingException;
|
|
|
|
|
}
|
|
|
|
|
throw new IllegalStateException(underlyingException);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|