-
Notifications
You must be signed in to change notification settings - Fork 493
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
Lists created from Stream.toList() cannot be rendered correctly #948
Comments
I have not been able to reproduce this, your scenario works for me in 3.0.15. Please provide a sample project (ideally Spring Boot -based) demonstrating the issue. |
Hi Daniel The whole point is not to use Spring. Spring injects the custom dialect, and with that custom dialect, i think it works fine. The problem is when you use the standard Thymleaf dialect. I'm attaching the simple test app. There 4 lines marked with "works" or "does not work", just uncomment each of them to compare results. |
Hi @grzegorzbor I checked your sample project and I think this is just a typo, instead of
it should be
Otherwise, you are not calling the isEmpty() method but asking Thymeleaf to print the value of the property "isEmpty". The same happened to me this morning and I arrived to your issue report :-) |
Hmm i doubt it is the case. Firstly, the error reported by thymeleaf was so it quite clearly tries to call the isEmpty() method. Secondly, it doesn't explain why it fails on the Stream.toList(), but works fine with Stream.collect(Collectors.toList()) |
Thymeleaf 3.0.15, no Spring
Create a list from Stream, using the new Stream.toList() method (new method added in java 17 i think), and add this list to the Thymeleaf model.
Then in Thymeleaf template, call size() or isEmpty() on this list , e.g. th:if="${list.isEmpty}"
and thymeleaf throws the exception:
Unable to make public boolean java.util.ImmutableCollections$ListN.isEmpty() accessible: module java.base does not "opens java.util" to unnamed module
The workaround is to use the "old style" Stream.collect(Collectors.toList()) - this works fine.
The text was updated successfully, but these errors were encountered: