Joerg Heinicke schrieb:
> On 27.12.2006 14:03, Carsten Ziegeler wrote:
> 
>>>> Line 50 of the PoolableProxyHandler is
>>>>
>>>> RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
>>>>  
>>>> RequestAttributes.SCOPE_REQUEST);
> 
>> I removed our own implementation in favour of Spring's
>> RequestContextHolder. The attributes are used to keep track of poolable
>> components and to release them when the request is finished.
>> Therefore you should add the Spring's request context listener to your
>> web.xml (I added it to web.xml in svn); this listener requires servlet
>> spec 2.4.
> 
> Wouldn't it be better to use 
> RequestContextHolder.currentRequestAttributes() (instead of 
> getRequestAttributes()) then? It has an additional null check and fails 
> early with an IllegalStateException with a quite clear error message. 
> This prevents NPEs like the one above.
> 
Yes, you're right. I used this approach in the rest of our code (at
least I *think* I used it...) :)

Carsten

-- 
Carsten Ziegeler - Chief Architect
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Reply via email to