How to Properly Implement ServletInputStream

18 Views Asked by At

I have a project that requires me to intercept requests and modify the request body before it arrive in a spring controller.

The article from baeldung shows how this might be achieved.

Yet, the article skip over the implementation of the setReadListener interface of the ServletInputStream.

I'm wondering what would be the consequence of not implementing the setReadListener? Based on some readings, the method seems to relate to the servlet specifications which is the basis for asynchronous processing. I'm assuming that it will cause some troubles when asychronous processing is involved (webflux? or maybe even spring MVC with asynchronous processing enabled).

If so, I am interested on a way to properly implement this setReadListener method. The spec is actually pretty simple, but I found no way to transfer the existing listeners from the original ServletInputStream to mine. Any help would be appreciated, preferable without resorting into reflection technique.

Thanks in advance.

0

There are 0 best solutions below