From 613b4d182b23b474db4e43257cf75ef8454e6bdf Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Nov 2009 13:42:07 +0000 Subject: [PATCH] avoid potential NPE (SPR-6300) --- .../org/springframework/test/web/ModelAndViewAssert.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java b/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java index a938146936..5f5930ffcf 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java +++ b/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.springframework.util.ObjectUtils; import org.springframework.web.servlet.ModelAndView; /** @@ -180,8 +181,8 @@ public abstract class ModelAndViewAssert { */ public static void assertViewName(ModelAndView mav, String expectedName) { assertCondition(mav != null, "ModelAndView is null"); - assertCondition(expectedName.equals(mav.getViewName()), "View name is not equal to '" + expectedName + - "' but was '" + mav.getViewName() + "'"); + assertCondition(ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()), + "View name is not equal to '" + expectedName + "' but was '" + mav.getViewName() + "'"); }