You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only way to set it to false is by removing the key completely.
In fact, many of these properties are behaving wrongly, and the only key that works as it should is serialize-nulls, which properly accepts true and false values.
But the fact that it works is thanks to the PR #16323 from 2019, which added .whenTrue() after the .map(...).
(I don't know if the fix was this exact PR or not, I only know that current GsonAutoConfiguration from spring-boot-autoconfigure-3.2.2 has the version with .whenTrue() added to it.)
spring:
gson:
disable-html-escaping: false
Can we do the same thing (add .whenTrue()) to all the other relevant options as well?
I couldn't quickly find more relevant issues, but I found stack overflow question where someone was also confused by this behavior.
The text was updated successfully, but these errors were encountered:
wilkinsona
changed the title
Gson - Config spring.gson.disable-html-escaping: false disables html escaping
Several gson properties, including spring.gson.disable-html-escaping, do not behave correctly when set to false
Feb 12, 2024
Verified by unit tests. This is very confusing.
false
is treated astrue
, because the configurer for this only checks if there's ANY value present (it usesalwaysApplyingWhenNonNull
):https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java#L80C46-L80C71
The only way to set it to false is by removing the key completely.
In fact, many of these properties are behaving wrongly, and the only key that works as it should is
serialize-nulls
, which properly accepts true and false values.But the fact that it works is thanks to the PR #16323 from 2019, which added
.whenTrue()
after the.map(...)
.(I don't know if the fix was this exact PR or not, I only know that current GsonAutoConfiguration from spring-boot-autoconfigure-3.2.2 has the version with
.whenTrue()
added to it.)Can we do the same thing (add
.whenTrue()
) to all the other relevant options as well?I couldn't quickly find more relevant issues, but I found stack overflow question where someone was also confused by this behavior.
The text was updated successfully, but these errors were encountered: