Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 禁用ServletRequest实例的重用_Java_Webserver_Jetty - Fatal编程技术网

Java 禁用ServletRequest实例的重用

Java 禁用ServletRequest实例的重用,java,webserver,jetty,Java,Webserver,Jetty,是否可以为每个请求禁用ServletRequest实例的重用?看起来该实例被多次重用(可能每个TCP会话绑定?Jetty在请求之间回收org.eclipse.Jetty.server.Request对象 这是正常的,在Servlet规范的定义范围内,许多容器都这样做 在容器分派之外,请小心使用HttpServletRequest/ServletRequest/Request对象 如果您是从AsyncContext使用它,您应该只在容器调用时使用它,而不是从任何其他点或任何其他线程调用它(除非您1

是否可以为每个请求禁用ServletRequest实例的重用?看起来该实例被多次重用(可能每个TCP会话绑定?

Jetty在请求之间回收
org.eclipse.Jetty.server.Request
对象

这是正常的,在Servlet规范的定义范围内,许多容器都这样做

在容器分派之外,请小心使用HttpServletRequest/ServletRequest/Request对象


如果您是从AsyncContext使用它,您应该只在容器调用时使用它,而不是从任何其他点或任何其他线程调用它(除非您100%确定您正确地处理了线程,并且准备好处理来自非容器线程的AsyncContext的数千个角落中的一个)您可以在规范中看到的内容:

3.13 Lifetime of the Request Object
Each request object is valid only within the scope of a servlet’s service method, or
within the scope of a filter’s doFilter method, unless the asynchronous processing
is enabled for the component and the startAsync method is invoked on the request
object. In the case where asynchronous processing occurs, the request object remains
valid until complete is invoked on the AsyncContext. Containers commonly recycle
request objects in order to avoid the performance overhead of request object
creation. The developer must be aware that maintaining references to request objects
for which startAsync has not been called outside the scope described above is not
recommended as it may have indeterminate results.
In case of upgrade, the above is still true
容器通常是循环使用的 请求对象,以避免请求对象的性能开销 创作

它是特定于容器的


在这种情况下,它是特定于Jetty的。

为什么您认为“看起来”它会被重用?如果oldReq=req'true,请将实例存储在请求中的某个位置