Skip to content

Dev Tools reload and SpEL loaded classes within Thymeleaf templates #42690

Closed as not planned
@mvitz

Description

@mvitz

In one of our Thymeleaf templates we have the following code:

...
<td th:if="${foobar instanceof T(some.pkg.FooBar)}">Matches</td>
...

This generally works and when foobar is an instance of FooBar the td is shown.

But when I start the application with Dev Tools enabled, and I change something after reloading, the td is no longer shown.
After I suspected that class loading may be the issue, I added the following code:

<td th:text="${foobar.getClass().getClassLoader()}"></td>
<td th:text="${T(some.pkg.FooBar).getClassLoader()}"></td>

After each change and reload, this shows that the ClassLoader of the foobar instance is a new RestartClassLoader but the ClassLoader of the T(some.pkg.FooBar) stays the initial one and therefore the instanceof returns false.
I don't know if it's possible, but it would be nice if the class within the Thymeleaf SpEL would be loaded by the same ClassLoader instance that loads the rest of the web application, as this would not alter the application "logic" in that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions