Skip to content

Commit 04cd95f

Browse files
committed
fixed accidental test failures
1 parent 9a48f3f commit 04cd95f

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

org.springframework.beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ else if (input.getClass().isArray()) {
437437
protected Collection convertToTypedCollection(
438438
Collection original, String propertyName, Class requiredType, MethodParameter methodParam) {
439439

440+
boolean originalAllowed = requiredType.isInstance(original);
441+
Class elementType = null;
442+
if (methodParam != null) {
443+
elementType = GenericCollectionTypeResolver.getCollectionParameterType(methodParam);
444+
}
445+
if (elementType == null && originalAllowed &&
446+
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
447+
return original;
448+
}
449+
440450
Iterator it;
441451
try {
442452
it = original.iterator();
@@ -473,16 +483,6 @@ protected Collection convertToTypedCollection(
473483
return original;
474484
}
475485

476-
boolean originalAllowed = requiredType.isInstance(original);
477-
Class elementType = null;
478-
if (methodParam != null) {
479-
elementType = GenericCollectionTypeResolver.getCollectionParameterType(methodParam);
480-
}
481-
if (elementType == null && originalAllowed &&
482-
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
483-
return original;
484-
}
485-
486486
int i = 0;
487487
for (; it.hasNext(); i++) {
488488
Object element = it.next();
@@ -503,6 +503,18 @@ protected Collection convertToTypedCollection(
503503

504504
@SuppressWarnings("unchecked")
505505
protected Map convertToTypedMap(Map original, String propertyName, Class requiredType, MethodParameter methodParam) {
506+
boolean originalAllowed = requiredType.isInstance(original);
507+
Class keyType = null;
508+
Class valueType = null;
509+
if (methodParam != null) {
510+
keyType = GenericCollectionTypeResolver.getMapKeyParameterType(methodParam);
511+
valueType = GenericCollectionTypeResolver.getMapValueParameterType(methodParam);
512+
}
513+
if (keyType == null && valueType == null && originalAllowed &&
514+
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
515+
return original;
516+
}
517+
506518
Iterator it;
507519
try {
508520
it = original.entrySet().iterator();
@@ -539,18 +551,6 @@ protected Map convertToTypedMap(Map original, String propertyName, Class require
539551
return original;
540552
}
541553

542-
boolean originalAllowed = requiredType.isInstance(original);
543-
Class keyType = null;
544-
Class valueType = null;
545-
if (methodParam != null) {
546-
keyType = GenericCollectionTypeResolver.getMapKeyParameterType(methodParam);
547-
valueType = GenericCollectionTypeResolver.getMapValueParameterType(methodParam);
548-
}
549-
if (keyType == null && valueType == null && originalAllowed &&
550-
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
551-
return original;
552-
}
553-
554554
while (it.hasNext()) {
555555
Map.Entry entry = (Map.Entry) it.next();
556556
Object key = entry.getKey();

org.springframework.beans/src/test/java/test/beans/DerivedTestBean.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 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.
@@ -60,6 +60,10 @@ public String getBeanName() {
6060
return beanName;
6161
}
6262

63+
public void setActualSpouse(TestBean spouse) {
64+
setSpouse(spouse);
65+
}
66+
6367
public void setSpouseRef(String name) {
6468
setSpouse(new TestBean(name));
6569
}
@@ -82,4 +86,4 @@ public boolean wasDestroyed() {
8286
return destroyed;
8387
}
8488

85-
}
89+
}

org.springframework.beans/src/test/java/test/beans/TestBean.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ public void setSpouse(ITestBean spouse) {
200200
this.spouses = new ITestBean[] {spouse};
201201
}
202202

203-
public void setActualSpouse(TestBean spouse) {
204-
this.spouses = new ITestBean[] {spouse};
205-
}
206-
207203
public ITestBean getSpouse() {
208204
return (spouses != null ? spouses[0] : null);
209205
}

org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</property>
4545
</bean>
4646

47-
<bean id="pDavid" class="test.beans.TestBean" scope="prototype">
47+
<bean id="pDavid" class="test.beans.DerivedTestBean" scope="prototype">
4848
<property name="name"><value>David</value></property>
4949
<property name="age"><value>27</value></property>
5050
<property name="actualSpouse" value="Jen"/>

0 commit comments

Comments
 (0)