Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Async filters

On Tue, Nov 12, 2019 at 8:44 AM Simone Bordet <sbordet@xxxxxxxxxxx> wrote:
Hi,

On Tue, Nov 12, 2019 at 3:26 PM Nils Kilden-Pedersen <nilskp@xxxxxxxxx> wrote:
>
> I did try that, but it failed:
>
> java.lang.IllegalStateException: s=HANDLING rs=BLOCKING os=OPEN is=READY awp=false se=false i=true al=0
>         at org.eclipse.jetty.server.Request.getAsyncContext(Request.java:592)

This is probably because you did not call request.startAsync().

Correct.
 

> I didn’t pursue this much further, because it seemed to be fundamentally brittle.

It's not brittle, it's defined by the Servlet Specification and it's
the standard way to go.
Very likely your code is not correct.

> Also, isn’t the response fully committed when AsyncContext.complete() is called, i.e. it’s too late to set headers, such as cookies?

It's the application that calls AsyncContext.complete(), so you are in control.

Well, yes :-)

It’s about separation of concerns. The purpose of the filter is to do certain behavior across a number of servlets. If I have to implement the filter code inside each servlet, when complete() is called, then it sort of defeats the purpose, no?


 

Perhaps you should detail more your use case. If the cookie depends on
what the rest of the application does, then kind of seems wrong to set
it in a filter.

Why? The cookie contains information that depends on the outcome of various requests and in multiple steps. I started out setting it in the servlet(s), but ended up with multiple Set-Cookie. The filter is to ensure a single point of setting the cookie, which is easy in a sync servlet, but problematic (it seems) with async.


 

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top