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行为相关推荐

  1. java 超时中断_怎么在超时后中断任务的ExecutorService

    在超时后中断任务的ExecutorService 我在找一个行政服务可以提供超时的实现.提交给ExecutorService的任务如果花费的时间超过运行超时时间,就会中断.实现这样一个猛兽并不是那么困 ...

  2. Java学习笔记——Java程序运行超时后退出或进行其他操作的实现

    当程序进入死循环或者由于其他原因无法自行终止的时候,就需要强制退出程序了. 对于开发软件 Eclipse ,在程序执行超时后,可以点击 Terminate 按钮强制退出. 那么,我们可不可以通过程序设 ...

  3. java redirect 超时_会话超时后,Spring安全性不会重定向到上次请求的页面登录

    首先启用并发会话控制支持是在以下位置添加以下侦听器web.xml: org.springframework.security.web.session.HttpSessionEventPublisher ...

  4. Java学完后可以从事的工作岗位分享

    这个时代是互联网时代,也是Java人才稀缺的时代.由于中国人才缺口比较大,Java也迅速成为行业和市场的热点,从业领域是很宽广的.不管是科技领域,还是食品产业,零售业等等,都需要Java人才进行处理, ...

  5. java阻塞超时_JAVA防线程阻塞(超时控制)

    2.[代码]TimeoutThread /** * java线程超时控制的实现 * * 超时控制一般使用阻塞时间比较长的操作上,有可能是和远程数据库的连接,也有可能是网络下载,在程序超时后, 往往需要 ...

  6. Java培训出来后一般多少工资

    学完Java培训出来后一般多少工资呢?这是很多人都比较关心的一个问题,小编在这里告诉大家,java技术这个岗位分为初级.中级和高级,每个等级的工资情况也是不一样,来看看下面的详细介绍. Java培训出 ...

  7. java 实现接口后重写方法报错

    java 实现接口后重写方法报错 java 实现接口后重写方法报错 The method contextDestroyed(ServletContextEvent) of type InitListe ...

  8. 解决Spring的java项目打包后执行出现“无法读取方案文档...“、“原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是...”问题

    解决Spring的java项目打包后执行出现"无法读取方案文档..."."原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是..."问题 ...

  9. 一点一点看JDK源码(五)java.util.ArrayList 后篇之forEach

    一点一点看JDK源码(五)java.util.ArrayList 后篇之forEach liuyuhang原创,未经允许禁止转载 本文举例使用的是JDK8的API 目录:一点一点看JDK源码(〇) 代 ...

最新文章

  1. 面试Python开发的这道题超简单,我却搞砸了!
  2. 一步一个脚印学习WCF系列之WCF概要—WCF出现的目的(一)
  3. 复制本地文件完整路径
  4. python读取单元格的值csv,比较单元格值的csv文件python
  5. 11.2.7 练习题
  6. MySql学习15----MySql日志
  7. Service group - get entity set
  8. Android 应用开发(31)---界面原型设计
  9. 微软sql服务器开机自启,使用 SQL Server 服务启动选项
  10. 题目66:矩阵中的路径
  11. opencv怎么安装?opencv下载安装教程
  12. JAVA Map类compute方法详解及样例
  13. 漂亮的CSS背景颜色
  14. nginx.conf配置文件中timeout超时时间设置
  15. 计算机学院学生王鹏,王鹏-计算机与控制工程学院
  16. Windows 10 文件名太长 无法删除 复制 重命名
  17. 睡眠 应该用 a加权 c加权_CPA每日一练财管加权平均资本成本的计算
  18. Hadoop之——伪分布安装
  19. 深度推荐模型之NFM模型
  20. 在2022年需要使用的25个最佳GOOGLE CHROME扩展

热门文章

  1. 还驾驭不了4核? 别人已模拟出百万核心上的并行
  2. 【C/C++和指针】深度解析---指针与数组 【精华】
  3. 数学是成就卓越开发人员的必备技能
  4. 查看VMware上虚拟机的 ip 地址
  5. Esxi直通板载Sata
  6. [cerc2012][Gym100624B]20181013
  7. cocoapods的安装(这真是一个神奇的东西,每次安装的方法都不一样,而且很容易出现各种各样的错误)...
  8. C#中用WMI实现对驱动的查询
  9. androidpn的一次亲密接触(二)
  10. LAMP 系统性能调优,第 3 部分: MySQL 服务器调优(转)