-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpEL fails to recover from error during MIXED mode compilation #28043
Comments
I made a mistake, this problem is not happened between multiple threads. I remove the multi thread code, I still happened. |
Hi @happier233, Thanks for reporting your first issue for the Spring Framework. 👍 This appears to be a bug in SpEL with regard to state tracking for the Specifically, We'll fix it. |
Are you positive that the same error occurs without concurrent use of the shared If so, could you please share an example without concurrent access which demonstrates that? |
UpdateUsing a simplified version of the original example, I can reliably reproduce a stack trace similar to the following.
The key thing to note is:
Based on my current understanding of the issue, this means that the compiled expression |
Yes, I agree with that. In my project, I have an interface "Order" and there are multiple implementations. So I may invoke one SpelExpression with different implementations. |
In the implementation |
Do the evaluated/compiled expressions all invoke only methods defined in your Or does your expression invoke any method that is unique to a particular concrete implementation? |
This has been fixed in Although we recommend that you not use the MIXED compiler mode in SpEL when frequently changing types used in the expression (such as a custom variable), this fix should allow you to do so. However, keep in mind that the compiler will continually try to compile expressions (generating classes for them on the fly) only to throw them away later, and at some point the compiler will determine that it does not make sense to continue trying (due to the In other words, if you used MIXED mode in such scenarios you will not actually benefit from compiled expressions. In the particular example provided, you could introduce a common interface that each of the types used as the |
Affects: 5.2.13.RELEASE
I am testing spel performance, when I share a SpelExpression instance between multiple threads.
I tried set SpelCompilerMode to MIXED or IMMEDIATE and put a variable with different type in the context, then I triggered an exception.
If I set SpelCompilerMode to OFF, it works correctly. So I am confused, is spel thread safe?
I didn't find any description of spel's thread safety in the spring project document. I want to ask it's a spel thread safe bug or spel is not thread safe when compile is enable.
Here is my test code:
Here is the excpetion stack:
The text was updated successfully, but these errors were encountered: