From ed5afa1a717f53a49a83b2ea92b6ad033178f83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Fri, 23 Feb 2018 20:45:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/componet/fallback/AuthFallbackProvider.java | 8 ++++++-- .../gateway/componet/fallback/UpmsFallbackProvider.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/AuthFallbackProvider.java b/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/AuthFallbackProvider.java index 92e0285c..10c53c93 100644 --- a/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/AuthFallbackProvider.java +++ b/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/AuthFallbackProvider.java @@ -20,9 +20,11 @@ import java.io.InputStream; @Slf4j @Component public class AuthFallbackProvider implements FallbackProvider { + + private static final String AUTH_SERVICE_DISABLE = "授权模块不可用"; + @Override public ClientHttpResponse fallbackResponse(Throwable cause) { - log.error("调用:{} 异常:{}", getRoute(), cause.getMessage()); return new ClientHttpResponse() { @Override public HttpStatus getStatusCode() { @@ -46,9 +48,11 @@ public class AuthFallbackProvider implements FallbackProvider { @Override public InputStream getBody() { if (cause != null && cause.getMessage() != null) { + log.error("调用:{} 异常:{}", getRoute(), cause.getMessage()); return new ByteArrayInputStream(cause.getMessage().getBytes()); } else { - return new ByteArrayInputStream("授权模块不可用".getBytes()); + log.error("调用:{} 异常:{}", getRoute(), AUTH_SERVICE_DISABLE); + return new ByteArrayInputStream(AUTH_SERVICE_DISABLE.getBytes()); } } diff --git a/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/UpmsFallbackProvider.java b/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/UpmsFallbackProvider.java index ff752939..39889f0d 100644 --- a/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/UpmsFallbackProvider.java +++ b/pig-gateway/src/main/java/com/github/pig/gateway/componet/fallback/UpmsFallbackProvider.java @@ -20,9 +20,11 @@ import java.io.InputStream; @Slf4j @Component public class UpmsFallbackProvider implements FallbackProvider { + + private static final String UPMS_SERVICE_DISABLE = "权限管理模块不可用"; + @Override public ClientHttpResponse fallbackResponse(Throwable cause) { - log.error("调用:{} 异常:{}", getRoute(), cause.getMessage()); return new ClientHttpResponse() { @Override public HttpStatus getStatusCode() { @@ -46,9 +48,11 @@ public class UpmsFallbackProvider implements FallbackProvider { @Override public InputStream getBody() { if (cause != null && cause.getMessage() != null) { + log.error("调用:{} 异常:{}", getRoute(), cause.getMessage()); return new ByteArrayInputStream(cause.getMessage().getBytes()); } else { - return new ByteArrayInputStream("权限管理模块不可用".getBytes()); + log.error("调用:{} 异常:{}", getRoute(), UPMS_SERVICE_DISABLE); + return new ByteArrayInputStream(UPMS_SERVICE_DISABLE.getBytes()); } }