[ 
https://issues.apache.org/jira/browse/CXF-6452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14584900#comment-14584900
 ] 

xfcjscn commented on CXF-6452:
------------------------------

This issue apply to both JAX-RS & JAX-WS, as this is part of spring integration.
Cxf service will be registed as spring bean, so spring's @Autowired can be used 
like below example.
Code example:
@Path("/sudoor/captcha")
@Produces(MediaType.TEXT_PLAIN)
public class CaptchaValidateController {
        @Autowired
        CaptchaEngine captchaEngine;
        
        @Autowired
        HttpSession session;

        @Autowired
        HttpServletRequest request;

        /**
         * parameter _captcha need to be availabe in request
         * @return
         * @throws Exception
         */
        @GET
        @Path("validate")
        public boolean validate() throws Exception {
                return captchaEngine.validate(request);
        }
}

In this case, the injected request is not the wrapped one(some filter may wrap 
the original request).
Spring servlet do the update in FrameworkServlet.processRequest() via 
RequestContextHolder.setRequestAttributes(), so that servlet can get latest 
one(wrapped one) in further process.
But in cxf, there is no code to update the RequestContextHolder, and it will 
always get the original one. 


> Spring Autowired annotataion on HttpServletRequest can not get latest request
> -----------------------------------------------------------------------------
>
>                 Key: CXF-6452
>                 URL: https://issues.apache.org/jira/browse/CXF-6452
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.1.0
>         Environment: Windows, Java HotSpot(TM) 64-Bit Server VM (build 
> 24.60-b09, mixed mode)
>            Reporter: xfcjscn
>              Labels: autowired, request, spring
>
> Autowired HttpServletRequest updated to wrapped version in 
> FrameworkServlet.processRequest() via 
> RequestContextHolder.setRequestAttributes(), so that further processes which 
> rely on Autowired HttpServletRequest can get wrapped version not original 
> version. 
> While CXF spring integration don't update it, and it will get original 
> request not wrapped version.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to