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

Stack overflow error with Documentation example #252

Closed
mguillet opened this issue Nov 13, 2015 · 3 comments
Closed

Stack overflow error with Documentation example #252

mguillet opened this issue Nov 13, 2015 · 3 comments
Labels

Comments

@mguillet
Copy link
Contributor

Here is a simple example extract from the document at:
http://vertx.io/docs/vertx-web/java/#_reroute

import io.vertx.core.AbstractVerticle;
import io.vertx.core.http.HttpServer;
import io.vertx.ext.web.Router;


public class RerouteExample extends AbstractVerticle {

  @Override
  public void start() throws Exception {
    HttpServer server = vertx.createHttpServer();

    Router router = Router.router(vertx);

    router.get("/some/path").handler(routingContext -> {

      routingContext.put("foo", "bar");
      routingContext.next();

    });

    router.get("/some/path/B").handler(routingContext -> {
      routingContext.response().end();
    });

    router.get("/some/path").handler(routingContext -> {
      routingContext.reroute("/some/path/B");
    });

    server.requestHandler(router::accept).listen(8081);

  }

}

If you run it like this:

$ vertx run RerouteExample.java &
$ curl http://localhost:8081/some/path

You'll end up with a StackOverflow error

Unexpected exception in route 
java.lang.StackOverflowError
    at java.security.AccessController.doPrivileged(Native Method)
    at java.io.PrintWriter.<init>(PrintWriter.java:116)
    at java.io.PrintWriter.<init>(PrintWriter.java:100)
    at java.util.logging.SimpleFormatter.format(SimpleFormatter.java:155)
    at java.util.logging.StreamHandler.publish(StreamHandler.java:211)
    at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:116)
    at java.util.logging.Logger.log(Logger.java:738)
    at io.vertx.core.logging.JULLogDelegate.log(JULLogDelegate.java:162)
    at io.vertx.core.logging.JULLogDelegate.log(JULLogDelegate.java:166)
    at io.vertx.core.logging.JULLogDelegate.error(JULLogDelegate.java:66)
    at io.vertx.core.logging.Logger.error(Logger.java:70)
    at io.vertx.ext.web.impl.RoutingContextImplBase.unhandledFailure(RoutingContextImplBase.java:106)
    at io.vertx.ext.web.impl.RoutingContextImpl.checkHandleNoMatch(RoutingContextImpl.java:102)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:94)
    at io.vertx.ext.web.impl.RoutingContextImpl.doFail(RoutingContextImpl.java:347)
    at io.vertx.ext.web.impl.RoutingContextImpl.fail(RoutingContextImpl.java:124)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:84)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:93)
    at io.vertx.ext.web.impl.RoutingContextImplBase.restart(RoutingContextImplBase.java:63)
    at io.vertx.ext.web.impl.RoutingContextImpl.reroute(RoutingContextImpl.java:277)
    at io.vertx.ext.web.RoutingContext.reroute(RoutingContext.java:354)
    at VertxPrincipal.lambda$start$2(VertxPrincipal.java:28)
    at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:220)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:78)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:93)
    at VertxPrincipal.lambda$start$0(VertxPrincipal.java:19)
@pmlopes
Copy link
Member

pmlopes commented Nov 25, 2015

I've tried to run this against the current 3.2.0-SNAPSHOT and it works as expected, i'll close this since it cannot be reproduced.

@mguillet
Copy link
Contributor Author

Yes, I've also tested with 3.2.0-SNAPSHOT today and it works now. Thanks!

@ThomasXY
Copy link

ThomasXY commented Dec 16, 2020

I use the version of vertx is 3.8.5, the issue come out again.
is there any limitation of the routing context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants