When I use "LocalVariableTableParameterNameDiscoverer#getParameterNames" method to parse a SpEL expression, I found some objects blocked. The direct cause is the "LocalVariableTableParameterNameDiscoverer#getParameterNames" method called "ConcurrentHashMap#computeIfAbsent" method, and "ConcurrentHashMap#" in JDK8 has a "synchronized" on its table nodes. My JDK version is 8 and I don't know whether it is a problem. Here is the demo code:
public class SpelDemo {
private static final LocalVariableTableParameterNameDiscorverer DISCOVERER = new LocalVariableTableParameterNameDiscoverer();
public String doParseKey(String key, JoinPoint joinPoint) {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
String[] parameterNames = DISCOVERER.getParameterNames(method); // objects blocked here, waiting for synchronized
// do something...
}
}
Can the "getParameterNames" method check the key(the executing method) if absent or not before calling "LocalVariableTableParameterNameDiscoverer#getParameterNames"? Or I have a problem with my usage?
Comment From: a544793138
MethodSignature can getParameterNames
Comment From: sdeleuze
LocalVariableTableParameterNameDiscoverer
has been deprecated in Spring Framework 6 as we recommend using StandardReflectionParameterNameDiscoverer
with Java compilation using -parameters
instead. Could you check if that's relevant for your use case?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: zzzhangyxi
Ok. The problem caused by ConcurrentHashMap in jdk8. When using higher jdk version, like jdk 17 in spring 6, I think it will no longer be a problem. I will check it again later. Thank you very much for replying me.
---Original--- From: "Sébastien @.> Date: Thu, Jan 5, 2023 19:03 PM To: @.>; Cc: @.**@.**>; Subject: Re: [spring-projects/spring-framework] Causes performance issues whenparsing Spel using LocalVariableTableParameterNameDiscoverer (Issue #29244)
LocalVariableTableParameterNameDiscoverer has been deprecated in Spring Framework 6 as we recommend using StandardReflectionParameterNameDiscoverer with Java compilation using -parameters instead. Could you check if that's relevant for your use case?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.