<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Unexpected behaviour is too common phrase - got it<div><br></div><div>As i sad i’ve experienced it in <a href="https://github.com/spring-projects/spring-framework/blob/main/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java">https://github.com/spring-projects/spring-framework/blob/main/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java</a></div><div><br></div><div>Error on ThreadLocal#set in finally section there lead to leaving wrong state of TL (in my case it was non-null value into TL, that Spring’s AOP treats like “part of recursion calls” and AOP will return null insteadof expected value (for all execution in such “poisoned” thread)</div><div><br></div><div>I believe that the same situation is possible with ThreadLocal#remove too</div><div><br><br><div dir="ltr"><blockquote type="cite">29 сент. 2023 г., в 05:37, David Holmes <david.holmes@oracle.com> написал(а):<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><span>On 29/09/2023 6:33 am, Егор Зиборов wrote:</span><br><blockquote type="cite"><span>Hello, Alan</span><br></blockquote><blockquote type="cite"><span>I’ve experienced SO in ThreadLocal#set on my production instance</span><br></blockquote><blockquote type="cite"><span>(more than that it‘s happened in Spring’s ExposeInvocationInterceptor</span><br></blockquote><blockquote type="cite"><span>that uses TL as context storage)As a result of SO in ThreadLocal</span><br></blockquote><blockquote type="cite"><span>we’ve experienced unexpected errors with Spring AOP, but I’m sure</span><br></blockquote><blockquote type="cite"><span>that it could affects lots of frameworks</span><br></blockquote><span>SOE will nearly always lead to unexpected errors, so that in itself is not sufficient justification for trying to apply ReservedStackAccess. We added RSA to address an insidious situation where SOE would leave ReentrantLocks in a broken state - and we wanted ReentrantLock to be as reliable as built-in monitor locks (or as near as feasible). So you need a very strong case to apply RSA elsewhere. You also need to be sure that the stack needed from the annotated method is small enough for the RSA mechanism to protect. Also note that RSA doesn't prevent SOE it simply defers it out of the critical code protected by SOE, so the problem is simply pushed to the caller.</span><br><span></span><br><span>Just my 2c.</span><br><span></span><br><span>David</span><br><span></span><br><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>28 сент. 2023 г., в 19:55, Alan Bateman <Alan.Bateman@oracle.com> написал(а):</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>On 28/09/2023 17:21, Егор Зиборов wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Hello, everyone</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>I'm new there and writing this letter during advice of Dalibor Topic</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>I faced an issue with SOE in ThreadLocal and want to add this java9 annotation on ThreadLocal#set. Does anyone have any concerns about it?</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>This annotation is for very core/critical areas that are particularly sensitive to SO. Did the SO that you observe just happen to be in ThreadLocal.set or is there more to this story? Asking because there are dozens places in java.base where the argument could be made but we have to be very careful to not sprinkle it about.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-Alab</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></div></blockquote></div></body></html>