fixed AbstractBindingResult to avoid NPE in "hashCode()" if target is null (SPR-7682)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3857 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
0b82100930
commit
ad67d91646
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.beans.PropertyEditorRegistry;
|
import org.springframework.beans.PropertyEditorRegistry;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -337,13 +338,13 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
||||||
}
|
}
|
||||||
BindingResult otherResult = (BindingResult) other;
|
BindingResult otherResult = (BindingResult) other;
|
||||||
return (getObjectName().equals(otherResult.getObjectName()) &&
|
return (getObjectName().equals(otherResult.getObjectName()) &&
|
||||||
getTarget().equals(otherResult.getTarget()) &&
|
ObjectUtils.nullSafeEquals(getTarget(), otherResult.getTarget()) &&
|
||||||
getAllErrors().equals(otherResult.getAllErrors()));
|
getAllErrors().equals(otherResult.getAllErrors()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getObjectName().hashCode() * 29 + getTarget().hashCode();
|
return getObjectName().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue