Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error cannot be forwarded to user-facing Mono with Spring Boot 2.0.0.RC1 and reactor-core:3.1.3.RELEASE #270

Closed
smaldini opened this issue Feb 2, 2018 · 3 comments
Labels
status/duplicate This is a duplicate of another issue
Milestone

Comments

@smaldini
Copy link
Contributor

smaldini commented Feb 2, 2018

Moving issue by @CyrillK from reactor/reactor-core#1055

Expected behavior

Mono catches the error and returns.

Actual behavior

Mono doesn't catch the error and never returns.

Steps to reproduce

springBootVersion = '2.0.0.RC1'

Suppose we have a simple spring boot application

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

with a simple controller which proxies the request to somewhere else

@RestController
public class HelloController {

    private static final ParameterizedTypeReference<String> TYPE_REF = new ParameterizedTypeReference<String>() {
    };

    private final WebClient webClient = WebClient.builder().baseUrl("http://localhost:9999").build();

    @GetMapping("/hello")
    public Mono<String> handle() {
        return webClient.get().uri("/remote").exchange().flatMap(f -> f.bodyToMono(TYPE_REF));
    }
}

and a test

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;

@RunWith(SpringRunner.class)
@SpringBootTest
public class HelloControllerTest {

    private WireMockServer wireMockServer;

    @Autowired
    private HelloController helloController;

    @Before
    public void before() {
        wireMockServer = new WireMockServer(9999);
        wireMockServer.start();
    }

    @After
    public void after() {
        if (wireMockServer.isRunning()) {
            wireMockServer.stop();
        }
    }

    @Test
    public void testThisThing2() {
        wireMockServer.givenThat(get("/remote").willReturn(aResponse().withFault(Fault.CONNECTION_RESET_BY_PEER)));
        StepVerifier.create(helloController.handle()).expectError().log().verify();
    }
}

The test never finishes and there are a lot of exceptions in logs like

14:13:58.425 [reactor-http-nio-2] DEBUG reactor.ipc.netty.http.client.HttpClient - [id: 0xebb43522, L:/127.0.0.1:61102 - R:localhost/127.0.0.1:9999] EXCEPTION: java.io.IOException: Connection reset by peer
java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
	at sun.nio.ch.IOUtil.read(IOUtil.java:192)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
	at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1108)
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:345)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:126)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
	at java.lang.Thread.run(Thread.java:748)
14:13:58.425 [qtp45822040-31] DEBUG org.eclipse.jetty.io.WriteFlusher - write: WriteFlusher@5db42ae7{IDLE}->null [HeapByteBuffer@48b4cd12[p=0,l=140,c=8192,r=140]={<<<HTTP/1.1 200 OK\r\n....v20171121)\r\n\r\n>>>\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}]
14:13:58.425 [qtp45822040-31] DEBUG org.eclipse.jetty.io.WriteFlusher - update WriteFlusher@5db42ae7{WRITING}->null:IDLE-->WRITING
14:13:58.425 [reactor-http-nio-2] DEBUG reactor.ipc.netty.channel.ChannelOperations - [id: 0xebb43522, L:/127.0.0.1:61102 - R:localhost/127.0.0.1:9999] [HttpClient] Connection closed remotely
java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
	at sun.nio.ch.IOUtil.read(IOUtil.java:192)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
	at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1108)
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:345)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:126)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
	at java.lang.Thread.run(Thread.java:748)
14:13:58.425 [reactor-http-nio-2] DEBUG reactor.ipc.netty.http.client.HttpClient - [id: 0xebb43522, L:/127.0.0.1:61102 - R:localhost/127.0.0.1:9999] CLOSE

and

14:13:58.426 [reactor-http-nio-2] ERROR reactor.ipc.netty.channel.ContextHandler - Error cannot be forwarded to user-facing Mono
java.io.IOException: Connection closed prematurely
	at reactor.ipc.netty.http.client.HttpClientOperations.onInboundClose(HttpClientOperations.java:262)
	at reactor.ipc.netty.channel.ChannelOperationsHandler.channelInactive(ChannelOperationsHandler.java:110)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75)
	at io.netty.handler.codec.http.HttpContentDecoder.channelInactive(HttpContentDecoder.java:205)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelInactive(CombinedChannelDuplexHandler.java:420)
	at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377)
	at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342)
	at io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:282)
	at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:223)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
	at io.netty.handler.logging.LoggingHandler.channelInactive(LoggingHandler.java:167)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1407)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:925)
	at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
	at java.lang.Thread.run(Thread.java:748)
14:13:58.426 [reactor-http-nio-2] DEBUG reactor.ipc.netty.http.client.HttpClient - [id: 0xebb43522, L:/127.0.0.1:61102 ! R:localhost/127.0.0.1:9999] UNREGISTERED

Reactor Core version

| +--- org.springframework.boot:spring-boot-starter-reactor-netty:2.0.0.RC1
| | --- io.projectreactor.ipc:reactor-netty:0.7.3.RELEASE

io.projectreactor:reactor-core:3.1.3.RELEASE

JVM version (e.g. java -version)

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

OS version (e.g. uname -a)

Darwin MGBKK186094-409 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64 i386 MacBookPro14,3 Darwin

@smaldini smaldini added this to the 0.7.4.RELEASE milestone Feb 2, 2018
@smaldini
Copy link
Contributor Author

smaldini commented Feb 5, 2018

Seems similar with #257

@violetagg
Copy link
Member

yes #257 (comment)

@violetagg violetagg added the status/duplicate This is a duplicate of another issue label Feb 6, 2018
@violetagg
Copy link
Member

Closed via #272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/duplicate This is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants