Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThymeleafEvaluationContext survives Spring Boot DevTools restart #328

Open
mvitz opened this issue Oct 21, 2024 · 0 comments
Open

ThymeleafEvaluationContext survives Spring Boot DevTools restart #328

mvitz opened this issue Oct 21, 2024 · 0 comments

Comments

@mvitz
Copy link

mvitz commented Oct 21, 2024

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.

A simple reproducer can be found at https://github.com/mvitz/devtools-thymeleaf-classloader

The README contains a screenshot of the index page after the initial start and a second one after adding just a blank line to the Application.java file and letting the DevTools reload happen.

This was originally reported to Spring Boot at spring-projects/spring-boot#42690 and Phil Webb pointed me here.

@mvitz mvitz changed the title ThymeleafEvaluationContext survices Spring Boot DevTools restart ThymeleafEvaluationContext survives Spring Boot DevTools restart Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant