Environment:
Issue:
The "reverse proxy servlet" is mapped to the URL "/visual-analytics/proxy/*".
There is another "filter" that is mapped to the URL "/visual-analytics/proxy/elasticsearch/.kibana/search/*" in which a “ContinuationListener” is being used as indicated by the following code snippet:
ContinuationSupport.getContinuation(myRequestWrapper).addContinuationListener(new ContinuationListener() {
@Override
public void onTimeout(Continuation continuation) {
logger.log(Level.WARNING, "Request timeout...");
}
@Override
public void onComplete(Continuation continuation) {
HttpServletResponse httpResponse = (HttpServletResponse)continuation.getServletResponse();
if (httpResponse.getStatus() == HttpServletResponse.SC_OK || httpResponse.getStatus() == HttpServletResponse.SC_CREATED ) {
//some business logic
}
}
});
chain.doFilter(myRequestWrapper, response);
The above ContinuationListener was working fine with Jetty version 8.1.15.v20140411 and the listener's onComplete() method was being called. But after upgrading the Jetty version to 9.3.14.v20161028, the ContinuationListener is no longer working i.e., neither the listener's onComplete() method nor the onTimeout() method is being called.
Any pointers on what could have gone wrong or how to debug this issue further would be greatly appreciated. Looking forward for any response...
FYI I fixed this issue as follows:
So the updated code segment looks like this:
chain.doFilter(myRequestWrapper, response);
AsyncContext asyncContext = myRequestWrapper.getAsyncContext();
asyncContext.addListener(new AsyncListener() {
@Override
public void onTimeout(AsyncEvent event) throws IOException
{
logger.log(Level.WARNING, "Async timeout...");
}
@Override
public void onStartAsync(AsyncEvent event) throws IOException
{
logger.log(Level.INFO, "Async start...");
}
@Override
public void onError(AsyncEvent event) throws IOException
{
logger.log(Level.SEVERE, "Async error...");
}
@Override
public void onComplete(AsyncEvent event) throws IOException
{
HttpServletResponse httpResponse = (HttpServletResponse) event.getAsyncContext().getResponse();
if (httpResponse.getStatus() == HttpServletResponse.SC_OK || httpResponse.getStatus() == HttpServletResponse.SC_CREATED ) {
//some business logic
}
}
}, myRequestWrapper, httpServletResponse);