日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java asynccontext,超时后的JavaEE 6 AsyncContext行为

發布時間:2023/12/20 java 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java asynccontext,超时后的JavaEE 6 AsyncContext行为 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

What is the exact behavior of AsyncContext after it times out? Does it still run and does it return response using getResponse()?

解決方案

Java Servlet 3.0 Maintenance Release on page 34 reads:

A call to this method - ServletRequest.startAsync(ServletRequest req,

ServletResponse res) - ensures that the response isn't committed when

the application exits out of the service method. It is committed when

AsyncContext.complete is called on the returned AsyncContext or the

AsyncContext times out and there are no listeners associated to handle

the time out. The timer for async time outs will not start until the

request and it’s associated response have returned from the container.

The AsyncContext could be used to write to the response from the async

thread. It can also be used to just notify that the response is not

closed and committed.

In the event that an asynchronous operation has timed out, the

container must run through these steps:

Invoke, at their onTimeout method, all AsyncListener instances registered with the ServletRequest on which the asynchronous operation

was initiated.

If none of the listeners called complete() or any of the dispatch() methods, perform an error dispatch with a status code equal

to HttpServletResponse.SC_INTERNAL_SERVER_ERROR.

If no matching error page was found, or the error page did not call complete() or any of the dispatch() methods, call complete()."

The last line above is of most importance - there'll be a call to AsyncContext.complete(). The javadoc says:

Completes the asynchronous operation that was started on the request

that was used to initialze this AsyncContext, closing the response

that was used to initialize this AsyncContext.

With AsyncContext closed, calls to most of its methods will throw IllegalStateException.

總結

以上是生活随笔為你收集整理的java asynccontext,超时后的JavaEE 6 AsyncContext行为的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。