diff --git a/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorController.java b/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorController.java index 2df9b4b6..a8af0df0 100644 --- a/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorController.java +++ b/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorController.java @@ -15,6 +15,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; @@ -39,6 +41,7 @@ import java.util.*; @Api(tags = "网关统计") @Log4j2 public class MonitorController { + private static final Logger logger = LoggerFactory.getLogger(MonitorController.class); @Autowired private RestTemplate restTemplate; @@ -151,9 +154,20 @@ public class MonitorController { outputStream.write(buffer, 0, len); len = inputStream.read(buffer); } + outputStream.close(); inputStream.close(); } catch (Exception e) { - e.printStackTrace(); + log.error("网关接口异常", e); + response.setStatus(500); + try { + ServletOutputStream outputStream = response.getOutputStream(); + outputStream.write("api error".getBytes()); + outputStream.flush(); + outputStream.close(); + } catch (Exception exception) { + + } + } }