Skip to content

Commit 5f77dce

Browse files
committed
SelectedValueComparator defensively handles null values in exhaustiveCompare
Issue: SPR-12001 (cherry picked from commit 980f971)
1 parent 0ef17a2 commit 5f77dce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/SelectedValueComparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -148,7 +148,7 @@ private static boolean exhaustiveCompare(Object boundValue, Object candidate,
148148
PropertyEditor editor, Map<PropertyEditor, Object> convertedValueCache) {
149149

150150
String candidateDisplayString = ValueFormatter.getDisplayString(candidate, editor, false);
151-
if (boundValue.getClass().isEnum()) {
151+
if (boundValue != null && boundValue.getClass().isEnum()) {
152152
Enum<?> boundEnum = (Enum<?>) boundValue;
153153
String enumCodeAsString = ObjectUtils.getDisplayString(boundEnum.name());
154154
if (enumCodeAsString.equals(candidateDisplayString)) {

0 commit comments

Comments
 (0)