我有一个SpringCloudGateway应用程序,它充当我的数据服务的网关。我的应用程序使用SSE在UI中推送通知。当我看到网关日志时,我的日志中充满了异常,如:
2019-01-25 07:39:13,807 ERROR [reactor-http-nio-3] org.springframework.web.server.adapter.HttpWebHandlerAdapter : Unhandled failure: Connection reset by peer, response
already set (status=200)
2019-01-25 07:39:13,809 ERROR [reactor-http-nio-3] org.springframework.http.server.reactive.ReactorHttpHandlerAdapter : Handling completed with error
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_181]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_181]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_181]
at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_181]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_181]
at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:403) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) [netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) [netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.forceFlush(SslHandler.java:1746) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:757) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:734) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
-----------------------------------------------------------------------------------------------------------------
2019-01-25 07:40:37,432 ERROR [reactor-http-nio-1] reactor.ipc.netty.channel.CloseableContextHandler : Handler failure while no child channelOperation was present
javax.net.ssl.SSLException: handshake timed out
at io.netty.handler.ssl.SslHandler.handshake(...)(Unknown Source) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
2019-01-25 07:40:39,512 ERROR [reactor-http-nio-3] org.springframework.web.server.adapter.HttpWebHandlerAdapter : Unhandled failure: Connection reset by peer, response
already set (status=200)
2019-01-25 07:40:39,513 ERROR [reactor-http-nio-3] org.springframework.http.server.reactive.ReactorHttpHandlerAdapter : Handling completed with error
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_181]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_181]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_181]
at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_181]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_181]
at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:403) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.forceFlush(SslHandler.java:1746) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:757) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:734) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) ~[netty-transport-4.1.22.Final.jar
!/:4.1.22.Final]
at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:358) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
----------------------------------------------------------------------------------------------------------------------------------------------
2019-01-25 07:43:47,048 ERROR [reactor-http-nio-3] org.springframework.web.server.adapter.HttpWebHandlerAdapter : Unhandled failure: Connection reset by peer, response
already set (status=200)
2019-01-25 07:43:47,049 ERROR [reactor-http-nio-3] org.springframework.http.server.reactive.ReactorHttpHandlerAdapter : Handling completed with error
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_181]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_181]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_181]
at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_181]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_181]
at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:403) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.forceFlush(SslHandler.java:1746) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:757) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:734) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) ~[netty-transport-4.1.22.Final.jar
!/:4.1.22.Final]
at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:358) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
at reactor.ipc.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:296) ~[reactor-netty-0.7.5.RELEASE.jar!/:0.7.5.RELEASE]
at reactor.ipc.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:465) ~[reactor-netty-0.7.5.RELEASE.jar!/:0.7.5.RELEASE]
at reactor.ipc.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:191) ~[reactor-netty-0.7.5.RELEASE.jar!/:0.7.5.RELEASE]
我有一个错误处理程序类:
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebExceptionHandler;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.io.IOException;
@Component
public class GlobalExceptionHandler implements WebExceptionHandler {
@Override
public Mono<Void> handle(ServerWebExchange exchange, Throwable exception) {
if (exchange.getResponse().isCommitted()) {
//for SSE connections, privents from filling up logs when connection is closed.
if(exception instanceof IOException && (exception.getMessage().contains("An established connection was aborted") || exception.getMessage().contains("Connection closed prematurely"))){
return exchange.getResponse().writeWith(Flux.just());
}
}
return Mono.error(exception);
}
}
但它仍在记录错误。如何使我的网关不写入日志。
我的pom文件是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>microservices-api-gateway</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>api-gateway</name>
<description>description</description>
<parent>
<artifactId>project-parent-pom</artifactId>
<groupId>xxx.xx</groupId>
<version>1.0.0</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-gateway-core
Due to defect in previous version higher version of cloud gateway was used-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-core</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<env.properties>config/${environment}_env.properties</env.properties>
<resources.version>3.0.2</resources.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>-->
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我的依赖关系树:
com.vh:microservices-api-gateway:jar:2.0.0-SNAPSHOT
[INFO] +- org.springframework.cloud:spring-cloud-starter-gateway:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-starter:jar:2.0.0.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-context:jar:2.0.0.RELEASE:compile
[INFO] | | | \- org.springframework.security:spring-security-crypto:jar:5.0.3.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-commons:jar:2.0.0.RELEASE:compile
[INFO] | | \- org.springframework.security:spring-security-rsa:jar:1.0.5.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-gateway-core:jar:2.0.1.RELEASE:compile
[INFO] | | \- io.projectreactor.addons:reactor-extra:jar:3.1.6.RELEASE:compile
[INFO] | | \- io.projectreactor:reactor-core:jar:3.1.5.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-webflux:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.0.0.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.4:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.4:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.0.0.RELEASE:compile
[INFO] | | \- io.projectreactor.ipc:reactor-netty:jar:0.7.5.RELEASE:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.22.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.1.22.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.22.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.1.22.Final:compile
[INFO] | | | \- io.netty:netty-transport:jar:4.1.22.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.22.Final:compile
[INFO] | | +- io.netty:netty-handler-proxy:jar:4.1.22.Final:compile
[INFO] | | | \- io.netty:netty-codec-socks:jar:4.1.22.Final:compile
[INFO] | | \- io.netty:netty-transport-native-epoll:jar:4.1.22.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.22.Final:compile
[INFO] | | \- io.netty:netty-transport-native-unix-common:jar:4.1.22.Final:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | +- org.springframework:spring-webflux:jar:5.0.4.RELEASE:compile
[INFO] | \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile
[INFO] | \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.0.0.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] | +- org.springframework:spring-aop:jar:5.0.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.0.4.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:5.0.3.RELEASE:compile
[INFO] | | +- org.springframework.security:spring-security-core:jar:5.0.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:5.0.4.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:5.0.3.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.0.4.RELEASE:compile
[INFO] +- org.springframework.cloud:spring-cloud-starter-netflix-hystrix:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-netflix-core:jar:2.0.0.RELEASE:compile
[INFO] | | \- org.springframework.boot:spring-boot-starter-aop:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.0.0.RELEASE:compile
[INFO] | | \- org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar:2.0.0.RELEASE:compile
[INFO] | | +- com.netflix.archaius:archaius-core:jar:0.7.6:compile
[INFO] | | | \- com.google.code.findbugs:jsr305:jar:3.0.1:runtime
[INFO] | | \- commons-configuration:commons-configuration:jar:1.8:compile
[INFO] | | \- commons-lang:commons-lang:jar:2.6:compile
[INFO] | +- com.netflix.hystrix:hystrix-core:jar:1.5.12:compile
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | | +- io.reactivex:rxjava:jar:1.3.6:compile
[INFO] | | \- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] | +- com.netflix.hystrix:hystrix-serialization:jar:1.5.12:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.9.4:runtime
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.4:compile
[INFO] | +- com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.5.12:compile
[INFO] | +- com.netflix.hystrix:hystrix-javanica:jar:1.5.12:compile
[INFO] | | +- org.apache.commons:commons-lang3:jar:3.7:runtime
[INFO] | | +- org.ow2.asm:asm:jar:5.0.4:runtime
[INFO] | | +- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] | | \- com.google.guava:guava:jar:15.0:compile
[INFO] | \- io.reactivex:rxjava-reactive-streams:jar:1.2.1:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] +- org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:jar:2.0.0.RELEASE:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.4:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.security.oauth:spring-security-oauth2:jar:2.2.1.RELEASE:compile
[INFO] | | +- org.springframework:spring-webmvc:jar:5.0.4.RELEASE:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.11:compile
[INFO] | | \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- org.springframework.security:spring-security-jwt:jar:1.0.9.RELEASE:compile
[INFO] | | \- org.bouncycastle:bcpkix-jdk15on:jar:1.56:compile
[INFO] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.56:compile
[INFO] | \- org.springframework:spring-web:jar:5.0.4.RELEASE:compile
[INFO] \- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-test:jar:2.0.0.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.RELEASE:test
[INFO] +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | \- net.minidev:json-smart:jar:2.3:test
[INFO] | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.7.10:test
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.7.10:test
[INFO] | \- org.objenesis:objenesis:jar:2.6:test
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] +- org.springframework:spring-core:jar:5.0.4.RELEASE:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.0.4.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:5.0.4.RELEASE:test
[INFO] \- org.xmlunit:xmlunit-core:jar:2.5.1:test
此错误不会发生在处理阶段,而是在响应的实际流传输期间。这是非常低级的,不在WebExceptionHandler
合同的范围内。
看起来您正在使用SpringFramework 5.0。x、 在本版本中,从5.0.6和#21229开始,此异常记录为警告级别。在Spring框架5.1中。x、 日志记录体验发生了重大变化,这些日志现在处于跟踪级别,因此默认情况下您不应该再看到这些日志。
同时,您可以将日志记录级别修改为<代码> ReaTrAtHypHANDLeLoad 类,只考虑错误级别日志。
我正在使用Spring Cloud Gateway Greenwich.sr1和Spring Boot 2.1.5。我正试图为我的下游服务创建一个网关。网关的部分工作是为下游请求提供全局错误页。当下游服务返回HTTP 403响应时,我希望网关提供一个合适的错误页面。 有没有不同的方法让它起作用?
统一错误处理 文档:https://eggjs.org/zh-cn/tutorials/restful.html 自定义一个异常基类 // app / exceptions / http_exceptions.js class HttpExceptions extends Error { constructor(msg='服务器异常', code=1, httpCode=400) {
我对spring mvc非常陌生抱歉,如果我问的是一个基本问题,我需要在我的spring 4 MVC,Jersey项目中维护全局异常处理,并向IOS移动应用程序返回JSON响应。现在,通过使用@ControllerAdvice和@ExceptionHandler,我创建了一个如下所示的类 请建议,如果上述方法是正确的,或有任何替代方法来处理所有发生在控制器,服务和DAO层的异常。
1.【强制】应用中不可直接使用日志系统(Log4j、Logback)中的API,而应依赖使用日志框架SLF4J中的API,使用门面模式的日志框架,有利于维护和各个类的日志处理方式统一。 import org.slf4j.Logger; import org.slf4j.LoggerFactory; private static final Logger logger = LoggerFactory
1.【强制】不要捕获Java类库中定义的继承自RuntimeException的运行时异常类,如:IndexOutOfBoundsException / NullPointerException,这类异常由程序员预检查来规避,保证程序健壮性。 正例:if(obj != null) {...} 反例:try { obj.method() } catch(NullPointerException e)
Middleware: 全局异常处理 我们在岩浆的实例其实已经注意到了,compose 的连接方式,让我们有能力精确控制异常。 Koa中间件最终行为强依赖注册顺序,比如我们这里要引入的异常处理,必须在业务逻辑中间件前注册,才能捕获后续中间件中未捕获异常,回想一下我们的调度器实现的异常传递流程。 <?php class ExceptionHandler implements Middleware