0

Does anyone have an idea why is being thrown listed exception after invoking /user URL? It quite strange because all works as is expected (upstream service handles a response from downstream and sends to a response to a client). Using Ratpack 1.4.1. Full code is available: https://github.com/peterjurkovic/ratpack-demo

Edit: I've just tried downgrade to version 1.3.3 and with this version of Ratpack it is not happening. Github issue created.

Edit 2: The issue should be resolved in the next version 1.4.2.

public class DownstreamUserService {

    Logger log = LoggerFactory.getLogger(DownstreamUserService.class);

    private HttpClient httpClient;
    private ObjectMapper mapper;
    private URI downstreamServerUri;

    @Inject
    public DownstreamUserService(HttpClient httpClient, Config config, ObjectMapper mapper) {
        this.httpClient = httpClient;
        this.mapper = mapper;
        try {
            downstreamServerUri = new URI("http://" + config.getHost() + ":" + config.getPort() + "/endpoint");
        } catch (URISyntaxException e) {
            log.error("",e);
            throw new RuntimeException(e);
        }
    }

    public Promise<User> load(){
        return httpClient.get( downstreamServerUri )
                .onError(e -> log.info("Error",e))
                .map( res -> mapper.readValue(res.getBody().getBytes(), User.class));

    }
}

Server

 public class App {

    static Logger log = LoggerFactory.getLogger(App.class); 

    public static void main(String[] args) throws Exception {
        RatpackServer.start(s -> s 
         // bindings..
         .handlers( chain -> chain

             .get("user", c -> {
                 DownstreamUserService service = c.get(DownstreamUserService.class);
                 service.load().then( user -> c.render( json(user) ));
             })
    }
}

Stacktrace:

    [2016-08-28 22:58:24,979] WARN  [ratpack-compute-1-2] i.n.c.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
io.netty.handler.codec.PrematureChannelClosureException: channel gone inactive with 1 missing response(s)
    at io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:261)
    at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:220)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:255)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:241)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:234)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1329)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:255)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:241)
    at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:908)
    at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:744)
    at io.netty.util.concurrent.SingleThreadEventExecutor.safeExecute(SingleThreadEventExecutor.java:451)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:418)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:306)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877)
    at ratpack.exec.internal.DefaultExecController$ExecControllerBindingThreadFactory.lambda$newThread$0(DefaultExecController.java:136)
    at ratpack.exec.internal.DefaultExecController$ExecControllerBindingThreadFactory$$Lambda$129/1240843015.run(Unknown Source)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
    at java.lang.Thread.run(Thread.java:745)
Peter Jurkovic
  • 2,686
  • 6
  • 36
  • 55
  • Are you terminating the server? How? If you're simply Ctrl+Cing it, then the client will eventually miss a heartbeat. That might explain it? – Paul Hicks Aug 28 '16 at 22:43
  • I am not aware of termination. Servers are still (should be) running after the response was received. Downstream server is just a wiremock server which just replies with mock data. Is running from an executable jar file. But is true, I am terminating it with CTRL-Cing – Peter Jurkovic Aug 28 '16 at 22:52
  • Does the exception happen when the messages are sent, or when you Ctrl-C? If the latter, then you can safely ignore it, or add code to nicely handle channels being correctly closed. – Paul Hicks Aug 28 '16 at 23:12
  • No, it is happening during the processing. – Peter Jurkovic Aug 28 '16 at 23:20
  • Can you provide a minimal project that reproduces the issue? I'm not seeing this issue locally. https://github.com/danhyun/ratpack-client-example – Dan Hyun Aug 29 '16 at 01:57
  • Sure, see the issue description. Thanks! – Peter Jurkovic Aug 29 '16 at 08:06

0 Answers0