Skip to content

Commit

Permalink
Merge branch '6.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
poutsma committed Jun 17, 2024
2 parents e4c881b + c38e989 commit b65b335
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
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;
Expand Down Expand Up @@ -115,7 +114,7 @@ public void initModel(NativeWebRequest request, ModelAndViewContainer container,
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
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.annotation.SessionAttributes;
Expand All @@ -43,7 +42,7 @@
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

Expand Down Expand Up @@ -151,7 +150,7 @@ void sessionAttribute() throws Exception {
void sessionAttributeNotPresent() throws Exception {
ModelFactory modelFactory = new ModelFactory(null, null, this.attributeHandler);
HandlerMethod handlerMethod = createHandlerMethod("handleSessionAttr", String.class);
assertThatExceptionOfType(HttpSessionRequiredException.class).isThrownBy(() ->
assertThatIllegalStateException().isThrownBy(() ->
modelFactory.initModel(this.webRequest, this.mavContainer, handlerMethod));

// Now add attribute and try again
Expand All @@ -164,7 +163,7 @@ void sessionAttributeNotPresent() throws Exception {
void sessionAttributeByType() throws Exception {
ModelFactory modelFactory = new ModelFactory(null, null, this.attributeHandler);
HandlerMethod handlerMethod = createHandlerMethod("handleTestBean", TestBean.class);
assertThatExceptionOfType(HttpSessionRequiredException.class).isThrownBy(() ->
assertThatIllegalStateException().isThrownBy(() ->
modelFactory.initModel(this.webRequest, this.mavContainer, handlerMethod));

// Now add attribute and try again
Expand Down

0 comments on commit b65b335

Please sign in to comment.