Skip to content

Java 21 ArrayList getLast is resolved by JavaBeanValueResolver #1163

@sebastian-dyroff

Description

@sebastian-dyroff

Java 21 introduced a getLast method. This breaks templates that use the {{@last}} directive on an empty list.

Using handlebars with Java < 21 the @last directive was resolved via the extendedContext in Context.java:583. Unfortunately with the JavaBeanResolver the getLast method matches the @last 'methodName' without the get prefix.

When an empty list is used getLast throws an NoSuchElement exception which is not handled correctly and leads to an error when evaluating the @last directive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions