Skip to content

Changes to Response ignored in "runAsFinally"-filter on exception #349

@uldall

Description

@uldall

I have created the following small test application:

public static void main(String... args) {
    Pippo pippo = new Pippo();
    pippo.GET("/hello/", routeContext -> {
    	routeContext.getResponse().ok();
    	throw new RuntimeException("Ouch");
    });
    pippo.ALL("/.*", routeContext -> {
        routeContext.getResponse().header("Cache-Control", "no-cache, no-store, must-revalidate");
	routeContext.getResponse().header("Pragma", "no-cache");
	routeContext.getResponse().header("Expires", "0");
	routeContext.next();
		
	System.out.println("Filter processed.");
    }).runAsFinally();
    pippo.start();
}

Which results in the following output when doing a GET on /hello/:

2017-02-07T09:07:50.438Z [XNIO-1 task-1] INFO  ro.pippo.core.PippoFilter - Pippo started (PROD)
2017-02-07T09:07:50.452Z [XNIO-1 task-1] ERROR ro.pippo.core.DefaultErrorHandler - Ouch
java.lang.RuntimeException: Ouch
	at com.gamblify.burgundy.content.Main.lambda$0(Main.java:22) ~[classes/:na]
	at ro.pippo.core.route.DefaultRouteContext.handleRoute(DefaultRouteContext.java:352) ~[pippo-core-1.1.0.jar:na]
...
Filter processed.

As the output shows the "/.*" filter is correctly called. The changes to the response is however ignored and so the HTTP headers are not added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions