While using HTMLUtils.htmlEscape(), it throws an IllegalArgumentException for null input values.

So to avoid this we need to add null checks on arguments explicitly.

Can't it be handled internally?

Comment From: sbrannen

Hi @spalve96,

Thanks for opening your first issue for the Spring Framework!

Regarding the behavior you have described, this is by design.

The package-info.java file in that package is annotated as follows.

@NonNullApi
@NonNullFields
package org.springframework.web.util;

Thus, the goal is to enforce strict non-null input values and non-null return values for all of those methods.

Accepting null input values would require us to return null values, which violates the above goal.

In light of that, I am closing this issue.