PDA

View Full Version : IllegalArgumentException in CustomizableTraceInterceptor



karsten
Jul 19th, 2005, 03:21 AM
Just want to point out a problem with the org.springframework.aop.interceptor.CustomizableTr aceInterceptor

We used it the following way:

<bean id="loggingInterceptor"
class="org.springframework.aop.interceptor.CustomizableTr aceInterceptor">
<property name="enterMessage">
<value>$&#91;targetClassShortName&#93;.$&#91;methodName&#93;&#40;$&#91;arguments&#93; &#41; Types&#40;$&#91;argumentTypes&#93;&#41;</value>
</property>
</bean>
To log the values, passed into our business facade.
The problem comes in with the the $[arguments] Placeholder. Passing a String containing a dollar sign $ throws a nice

java.lang.IllegalArgumentException&#58; Illegal group reference
at java.util.regex.Matcher.appendReplacement&#40;Matcher. java&#58;554&#41;
at org.springframework.aop.interceptor.CustomizableTr aceInterceptor.replacePlaceholders&#40;CustomizableTra ceInterceptor.java&#58;321&#41;
at org.springframework.aop.interceptor.CustomizableTr aceInterceptor.invokeUnderTrace&#40;CustomizableTraceI nterceptor.java&#58;274&#41;
at org.springframework.aop.interceptor.AbstractTraceI nterceptor.invoke&#40;AbstractTraceInterceptor.java&#58;77 &#41;
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed&#40;ReflectiveMethodInvocation.java &#58;144&#41;

So we throwed the arguments out of the logging.
Does anyone know about another solution? Are we doing something wrong here?
Besides this error this aop style of logging simply rocks. So easy and yet so powerful. Besides this little flaw.

robh
Jul 19th, 2005, 03:27 AM
Karsten,

Can you raise a JIRA issue for this and ask for it to be assigned to me. I'll put the fix in for 1.2.3.

Rob

robh
Jul 19th, 2005, 07:24 AM
Created a JIRA issue at SPR-1151 (http://opensource.atlassian.com/projects/spring/browse/SPR-1151). Issue is marked as resolved and the fix has been added to CVS.

Rob

karsten
Jul 19th, 2005, 11:04 AM
Rob,
thx a lot for this quick fix. Sorry for not putting it in Jira so fast.
I am amazed by the speed of your response. Thank you.
Cheers,
Karsten.

karsten
Jul 27th, 2005, 02:58 AM
Just downloaded the brand new 1.2.3 version. So I can confirm fix in Spring 1.2.3.
Thx again.

khaingn
Feb 1st, 2006, 06:36 PM
I tried to follow the above example. And I tried to get exception error, I could not see degug or log message anywhere. How Can I make to get these message?

I put the following def in ApplicationContext.xml

<bean id="traceInterceptor" class="org.springframework.aop.interceptor.CustomizableTr aceInterceptor">
<property name="enterMessage">
<value>$[targetClassShortName].$[methodName]($[arguments]) Types($[argumentTypes])</value>
</property>
<property name="exitMessage"><value>EXIT - {1}{2}</value></property>
<property name="exceptionMessage"><value>EXIT - {1}{2}</value></property>
</bean>

<bean id="wbxml-builder" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>xxx.r.builder.Builder</value></property>
<property name="interceptorNames">
<list>
<value>traceInterceptor</value>

Please help me to get this log?

Thanks,

Kai

scof
Feb 28th, 2008, 05:11 AM
Same problem with $[exception] placeholder remains in CustomizableTraceInterceptor. Strangely no one has been reported about it as sign '$' is quite frequently found in stack traces(e.g. in inner classes' names)