Remove use of ServletException in ModelFactory

This commit changes the use of HttpSessionRequiredException in
ModelFactory::initModel to an IllegalStateException, because the former
extends ServletException and cannot be used in WebFlux.

Closes gh-33043
This commit is contained in:
Arjen Poutsma
2024-06-17 14:19:10 +02:00
parent 3e0849a566
commit c38e9896c7
2 changed files with 4 additions and 6 deletions

View File

@@ -37,7 +37,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.HttpSessionRequiredException;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.support.WebDataBinderFactory;
@@ -115,7 +114,7 @@ public final class ModelFactory {
if (!container.containsAttribute(name)) {
Object value = this.sessionAttributesHandler.retrieveAttribute(request, name);
if (value == null) {
throw new HttpSessionRequiredException("Expected session attribute '" + name + "'", name);
throw new IllegalStateException("Expected session attribute '" + name + "'");
}
container.addAttribute(name, value);
}