Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] AspectJ pointcut matching arguments (args()) is not matching correctly

Hi,

I just posted this on StackOverflow, but then realized I might have better success asking a specific question like this here:

I've got an pointcut that I am trying to use with LTW.  I have 2 methods that I am trying to advise, each with a different parameter list.  However, they both have a single common parameter that I want.

These are the method signatures I want to advise:

       public static WorkflowModifierFlags authenticateUser(String username, String password, String ip, boolean webGUI, boolean realAuthentication)
    
       public static boolean loginJAAS(HttpServletRequest request, HttpServletResponse response, String username, String password, HttpSession session)


I've tried the following pointcut/advice, but it is failing; the username variable is sometimes getting injected with the IP address (ie: the args() from the first pointcut).

    @Before("(execution(public static * business.security.service.LoginManagerHelper.authenticateUser(..)) && args( username, ..)) || "
    + "(execution(public static * webapp.util.LoginManagerAction.loginJAAS(..)) && args( *, *, username, ..))" )
    public void setUsername(JoinPoint jp, String username) {
    // inject the username into the MDC
    MDCUtils.setUsername(username);
    }


I would have expected that the `args()` parameter is associated to the execution() method, but sometimes it would appear that it is "confused", and gives me the IP instead of the username.

Am I using AspectJ incorrectly, or is this a bug in the LTW?  I'm running AspectJ 1.6.13.

Thanks,

Eric


Back to the top