Probe registers multiple method invocations

Questions about YourKit Java Profiler
Post Reply
perehnbom
Posts: 2
Joined: Fri Nov 25, 2011 8:51 am

Probe registers multiple method invocations

Post by perehnbom »

I have a probe registering method invocations. In some cases yourkit registers 2 invocations when only one method call is executed.

This is the probe I have:

Code: Select all

@MethodPattern({"mydomain.webapp.integration.MyServiceFacade:*(*)"})
public class JspProbe {
    
    public static long onEnter(@MethodName String methodSignature, @This Object object) {    	
    	if(methodSignature.contains("getAccountDTO")){
    		System.out.println("ENTER |"+object +"|"+methodSignature+"|" + "( "+System.nanoTime()+")");
    	}
        return System.nanoTime();
    }
  
    public static void onReturn(@OnEnterResult long enterTime, @MethodName String methodSignature, @MethodParameterTypes String methodParameterTypes, @This Object object) {    	    	
    	
    	if(methodSignature.contains("getAccountDTO")){
    		System.out.println("RETURN |"+object +"|"+methodSignature+"|" + "( "+System.nanoTime()+")");
    	}    	    
    }
}
The method in MyServiceFacade that executes the code is the following:

Code: Select all

       public List<AccountDTO> getAccountDTOs(final List<AccountId> accountIds){
    	System.out.println("executing getAccountAndPositionsDTOs");
    	return new ArrayList<AccountDTO>()  
    }

And the outprint from the log is the following, which clearly shows that the method is executed once but the probe registers 2 calls.

Code: Select all

ENTER |[email protected]|getAccountDTOs|( 1558167984511865)
ENTER |[email protected]|getAccountDTOs|( 1558167991299882)
executing getAccountAndPositionsDTOs
RETURN |[email protected]|getAccountDTOs|( 1558167991458486)
RETURN |[email protected]|getAccountDTOs|( 1558167991774539)

The behaviour happens for some calls like this one, while most similar calls are registered correctly. If I change the method pattern and add the method name to it, the probe registers only one call:

Code: Select all

@MethodPattern({"mydomain.webapp.integration.MyServiceFacade:getAccountDTO(*)"})

We use Yourkit 10.0.2, Spring 3 running on jetty 7. I suspect that this post highlights the same bug:
http://forums.yourkit.com/viewtopic.php ... obe#p13595


regards Per Ehnbom
perehnbom
Posts: 2
Joined: Fri Nov 25, 2011 8:51 am

Re: Probe registers multiple method invocations

Post by perehnbom »

Corrections:
the first method pattern should be:

Code: Select all

@MethodPattern({"mydomain.webapp.integration.*:*(*)"})
the last method pattern should be:

Code: Select all

@MethodPattern({"mydomain.webapp.integration.MyServiceFacade:getAccountDTOs(*)"})
Anton Katilin
Posts: 6139
Joined: Wed Aug 11, 2004 8:37 am
Contact:

Re: Probe registers multiple method invocations

Post by Anton Katilin »

Hello Per

Maybe the probe is loaded twice from different locations.

What is the package of the probe class JspProbe?

Is it in mydomain.webapp.integration or in its sub-package?

How do you enable the probe?

Could you please specify startup option "debug=all" and provide the agent log. It should show which probes are applied.
I suspect that this post highlights the same bug:
viewtopic.php?f=3&t=3882&p=13609&hilit=probe#p13595
I think it is different issue.

Best regards,
Anton
Post Reply