eclipse-ee4j / mojarra

Mojarra, a Jakarta Faces implementation
Other
160 stars 109 forks source link

Commited response and PartialResponseWriter #5189

Closed unkle-jb closed 1 year ago

unkle-jb commented 1 year ago

Describe the bug

During the rendering of a (large) page, an error is thrown and a ExceptionHandler is triggered (Primefaces). Unfortunately, the response buffer is already comitted. Hence, no redirection towards the error page (through js scripts) can be done. It was workign with Mojarra 2.2.X but not with Mojarra 4.0 which we just migrated to.

Our understanding of the current situation is that the BufferSize is set in the DelayedInitPartialResponseWriter initalisation (it is a lazy getter) triggering an IllegalStateException from the Underlying Response (Tomcat in our case, Jetty would behave similarly).

Is there a reason not to check the extCtx.isComitted() before setting the ReponseBufferSize ?

Expected behavior

Getting a PartialResponseWriter evevn if response is in the comitted state (which was doable in Mojarra 2.2.X, and working as far as we can tell).

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Java 17 Mojarra 4.0 Primefaces 12 Tomcat 10

Commit (unfortunately, no more Jira...) https://github.com/javaee/mojarra/commit/a030c06cba7eba0303816fbec5fccfd1fc5c9cab

BalusC commented 1 year ago

I tried reproducing this but I was unable to find the proper configuration triggering this misbehavior. Can you perhaps provide a reproducer?

cc: @melloware

melloware commented 1 year ago

@unkle-jb you can use this little test project to create a simple reproducer: https://github.com/primefaces/primefaces-test/tree/jakarta

We have a 4.0 Jakarta branch all set and ready.

unkle-jb commented 1 year ago

@BalusC, @melloware Thanks ! Will try to get you a reproducer soon.

unkle-jb commented 1 year ago

That went easier than expected. Here is a short test project, which can be run with mojarra40 (mvn clean jetty:run -Pmojarra40): primefaces-test.zip

Try it with value 50 or 5000 for nbSentences in TestView.

Behaviour is different, and for (I'd say) bad reason. For info we managed to extend the PrimePartialViewContext in order to redefine the DelayedInitPartialResponseWriter. It is a bit Frankenstein-ish since we handle pure Mojarra issue with Primefaces overloading mechanism, but right now it "works" as before (ie Mojarra 2.2.X).

BalusC commented 1 year ago

Ok, reproduced and improved.