Skip to content

SpEL ternary expression is missing fallback part during parsing. #34117

@Mitsuki0710

Description

@Mitsuki0710

Having a Spring ternary expression "Did he win the race? ${['win'] ? 'Yes.' : "No.'}", PlaceholderParser will break it into two parts.

  1. TextPart - { text : "Did he win the race?" }
  2. SimplePlaceholderPart - { key : "['win'] ? 'Yes.'", fallback : "'No.'", text : "['win'] ? "'Yes.' : 'No.'" }

But while resolving the SimplePlaceholderPart context, it returns the key value of it which misses the fallback part (PlaceholderParser.class : L376).

Now, if try SpelExpression.doParseExpression("['win'] ? 'Yes.'"), this.eatToken(TokenKind.COLON);(InternalSpelExpressionParser.class : L155) will throw the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions