NPE in FunctionReference due to race condition in SpelExpression.getValue() [SPR-16255] #20802
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Alvaro Manuel Recio Perez opened SPR-16255 and commented
We have issues in a scenario in which several threads are evaluating the same expression (which include functions) in
IMMEDIATE
mode.org.springframework.expression.spel.standard.getValue()
includes the following piece of code:The call to
checkCompile()
goes through a synchronized block incompileExpression()
which ends up inorg.springframework.expression.spel.ast.FunctionReference.generateCode()
. Inside this method, the fieldthis.method
is accessed twice, as follows:However, the call to
this.ast.getValue(expressionState)
inorg.springframework.expression.spel.standard.getValue()
we saw earlier, which does not go through a synchronized block, ends up callingorg.springframework.expression.spel.ast.FunctionReference.executeFunctionJLRMethod()
. The first insruction of this method is:Because this code path is not synchronized, it may set
this.method
tonull
while the thread executingcheckCompile()
is running, causing a NullPointerException:Affects: 4.3.13, 5.0.2
Referenced from: commits 6a1fe0b, a9bad58
Backported to: 4.3.14
The text was updated successfully, but these errors were encountered: