Skip to content

NPE in Elvis Expression (ExitTypeDescriptor null) [SPR-12014] #16630

@spring-projects-issues

Description

@spring-projects-issues

Martin Frey opened SPR-12014 and commented

I just did a test run today with RC1 and an expression that was before does throw now an NPE during the evaluation.

I'm using Thymeleaf and the expression is using a "toplevel" variable cols which is optional and resolves to null in the current case.

${cols ?: 80}

In SPEL this resolves into the structure that i have attached as an image. As you can see the result is resolved properly, but the expression finally fails with an NPE in the class Elvis on line 59 as the testDescriptor is null at this point.

Probably it has something to do with the introduction of the class CompilablePropertyAccessor? I have found this code in the class PropertyOrFieldReference.

// line 366
if (ref.cachedReadAccessor instanceof CompilablePropertyAccessor) {
            CompilablePropertyAccessor accessor = (CompilablePropertyAccessor)this.ref.cachedReadAccessor;
            this.ref.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
       }

And on the Thymleaf side:


public class VariablesMapPropertyAccessor extends ReflectivePropertyAccessor {...}

Let me know if you need more info.


Affects: 4.1 RC1

Attachments:

Referenced from: commits 4b09fcc

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions