Skip to content

Commit 613b4d1

Browse files
committed
avoid potential NPE (SPR-6300)
1 parent 6ee17d2 commit 613b4d1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import java.util.Map;
2424
import java.util.Set;
2525

26+
import org.springframework.util.ObjectUtils;
2627
import org.springframework.web.servlet.ModelAndView;
2728

2829
/**
@@ -180,8 +181,8 @@ public static void assertSortAndCompareListModelAttribute(
180181
*/
181182
public static void assertViewName(ModelAndView mav, String expectedName) {
182183
assertCondition(mav != null, "ModelAndView is null");
183-
assertCondition(expectedName.equals(mav.getViewName()), "View name is not equal to '" + expectedName +
184-
"' but was '" + mav.getViewName() + "'");
184+
assertCondition(ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()),
185+
"View name is not equal to '" + expectedName + "' but was '" + mav.getViewName() + "'");
185186
}
186187

187188

0 commit comments

Comments
 (0)