-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Calum,
On 6/21/2011 4:26 AM, Calum wrote:
> On 20 June 2011 17:02, Christopher Schultz <chris@christopherschultz.net> wrote:
>> That depends on what Service.logHit does. If it only uses the
>> HttpServletRequest object during the method's lifetime, then everything
>> is fine. If it retains a reference to the request object, you will
>> probably end up with a problem.
>
> Oh, just gets the remoteAddr, requestURI, user-agent etc, and logs it
> to a DB, for example.
No problem. You are not retaining a reference to the request object in
that case.
>> Tomcat re-uses the same request and response objects for a long time,
>> and so multiple request processor threads will see the same object over
>> the life of the server. If any of that code retains a reference to the
>> request, by the time the object is re-referenced by the same code for
>> whatever reason, the object will have "moved on" and will almost
>> certainly be invalid (from the perspective of the code that cached it)
>> and might /actually/ be invalid (because it is between requests and
>> Tomcat has actively invalidated it).
>
> I assume that Tomcat won't reuse a request/response until activity on
> it has ended though?
Of course: during the transaction, the request and response objects
maintain sanity.
> Does it keep a pool of them?
Maybe. By default, a pool is used, but you can disable that if you are
having problems and can afford a bit of performance degradation.
Honestly, disabling that pooling should only be used when a fix is
needed immediately in production and should only be used temporarily
until your webapp is fixed.
> Thanks for your help in clarifying this for me, by the way.
No problem.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4ArbkACgkQ9CaO5/Lv0PBKBACdEZc+UXO/YMbZvJaeD276vySp
pJYAoLMwetgFC0HjKg/mWlC6WWKV+O6S
=lpby
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
|