Skip to content

Commit 50c578c

Browse files
committed
Polishing
1 parent c89d8ec commit 50c578c

File tree

13 files changed

+125
-85
lines changed

13 files changed

+125
-85
lines changed

build.gradle

+21-21
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ project("spring-tx") {
441441
compile(project(":spring-beans"))
442442
compile(project(":spring-core"))
443443
optional(project(":spring-aop"))
444-
optional(project(":spring-context")) // for JCA, @EnableTransactionManagement
444+
optional(project(":spring-context")) // for JCA, @EnableTransactionManagement
445445
optional("aopalliance:aopalliance:1.0")
446446
optional("javax.transaction:javax.transaction-api:1.2")
447447
optional("javax.resource:connector-api:1.5")
@@ -516,7 +516,7 @@ project("spring-jdbc") {
516516
compile(project(":spring-beans"))
517517
compile(project(":spring-core"))
518518
compile(project(":spring-tx"))
519-
optional(project(":spring-context")) // for JndiDataSourceLookup
519+
optional(project(":spring-context")) // for JndiDataSourceLookup
520520
optional("javax.transaction:javax.transaction-api:1.2")
521521
optional("com.mchange:c3p0:0.9.2.1")
522522
optional("org.hsqldb:hsqldb:${hsqldbVersion}")
@@ -533,8 +533,8 @@ project("spring-context-support") {
533533
compile(project(":spring-core"))
534534
compile(project(":spring-beans"))
535535
compile(project(":spring-context"))
536-
optional(project(":spring-jdbc")) // for Quartz support
537-
optional(project(":spring-tx")) // for Quartz support
536+
optional(project(":spring-jdbc")) // for Quartz support
537+
optional(project(":spring-tx")) // for Quartz support
538538
optional("javax.mail:javax.mail-api:1.4.7")
539539
optional("javax.cache:cache-api:1.0.0")
540540
optional("com.google.guava:guava:17.0")
@@ -550,8 +550,8 @@ project("spring-context-support") {
550550
exclude group: "xml-apis", module: "xml-apis"
551551
}
552552
testCompile("org.apache.poi:poi:3.10.1")
553-
testCompile("commons-beanutils:commons-beanutils:1.8.0") // for Velocity/JasperReports
554-
testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports
553+
testCompile("commons-beanutils:commons-beanutils:1.8.0") // for Velocity/JasperReports
554+
testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports
555555
testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
556556
testCompile("org.slf4j:slf4j-api:${slf4jVersion}")
557557
testRuntime("com.sun.mail:javax.mail:1.4.7")
@@ -565,20 +565,20 @@ project("spring-web") {
565565
description = "Spring Web"
566566

567567
dependencies {
568-
compile(project(":spring-aop")) // for JaxWsPortProxyFactoryBean
569-
compile(project(":spring-beans")) // for MultiPartFilter
568+
compile(project(":spring-aop")) // for JaxWsPortProxyFactoryBean
569+
compile(project(":spring-beans")) // for MultipartFilter
570570
compile(project(":spring-context"))
571571
compile(project(":spring-core"))
572572
provided("javax.servlet:javax.servlet-api:3.0.1")
573-
optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter
573+
optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter
574574
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
575575
optional("javax.portlet:portlet-api:2.0")
576576
optional("javax.el:javax.el-api:2.2.5")
577577
optional("javax.faces:javax.faces-api:2.2")
578578
optional("aopalliance:aopalliance:1.0")
579579
optional("com.caucho:hessian:4.0.7")
580580
optional("commons-fileupload:commons-fileupload:1.3.1")
581-
optional("org.apache.httpcomponents:httpclient:4.3.5")
581+
optional("org.apache.httpcomponents:httpclient:4.3.6")
582582
optional("org.apache.httpcomponents:httpasyncclient:4.0.2")
583583
optional("org.codehaus.jackson:jackson-mapper-asl:${jackson1Version}")
584584
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
@@ -711,8 +711,8 @@ project("spring-webmvc") {
711711
compile(project(":spring-expression"))
712712
compile(project(":spring-web"))
713713
provided("javax.servlet:javax.servlet-api:3.0.1")
714-
optional(project(":spring-context-support")) // for Velocity support
715-
optional(project(":spring-oxm")) // for MarshallingView
714+
optional(project(":spring-context-support")) // for Velocity support
715+
optional(project(":spring-oxm")) // for MarshallingView
716716
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
717717
optional("javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1")
718718
optional("net.sourceforge.jexcelapi:jxl:2.6.12")
@@ -764,7 +764,7 @@ project("spring-webmvc") {
764764
}
765765
testCompile("javax.validation:validation-api:1.0.0.GA")
766766
testCompile("org.hibernate:hibernate-validator:${hibVal4Version}")
767-
testCompile("org.apache.httpcomponents:httpclient:4.3.5")
767+
testCompile("org.apache.httpcomponents:httpclient:4.3.6")
768768
testCompile("commons-fileupload:commons-fileupload:1.3.1")
769769
testCompile("commons-io:commons-io:1.3")
770770
testCompile("joda-time:joda-time:${jodaVersion}")
@@ -915,13 +915,13 @@ project("spring-aspects") {
915915
rt("org.aspectj:aspectjrt:${aspectjVersion}")
916916
compile("org.aspectj:aspectjweaver:${aspectjVersion}")
917917
provided("org.eclipse.persistence:javax.persistence:2.0.0")
918-
optional(project(":spring-aop")) // for @Async support
919-
optional(project(":spring-beans")) // for @Configurable support
920-
optional(project(":spring-context")) // for @Enable* support
921-
optional(project(":spring-context-support")) // for JavaMail support
922-
optional(project(":spring-orm")) // for JPA exception translation support
923-
optional(project(":spring-tx")) // for JPA, @Transactional support
924-
testCompile(project(":spring-core")) // for CodeStyleAspect
918+
optional(project(":spring-aop")) // for @Async support
919+
optional(project(":spring-beans")) // for @Configurable support
920+
optional(project(":spring-context")) // for @Enable* support
921+
optional(project(":spring-context-support")) // for JavaMail support
922+
optional(project(":spring-orm")) // for JPA exception translation support
923+
optional(project(":spring-tx")) // for JPA, @Transactional support
924+
testCompile(project(":spring-core")) // for CodeStyleAspect
925925
testCompile(project(":spring-test"))
926926
testCompile("javax.mail:javax.mail-api:1.4.7")
927927
}
@@ -1157,7 +1157,7 @@ configure(rootProject) {
11571157
}
11581158
}
11591159

1160-
// Create an distribution that contains all dependencies (required and optional).
1160+
// Create a distribution that contains all dependencies (required and optional).
11611161
// Not published by default; only for use when building from source.
11621162
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
11631163
group = "Distribution"

spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

+4-1
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.
@@ -104,9 +104,11 @@ public class DefaultListableBeanFactoryTests {
104104

105105
private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class);
106106

107+
107108
@Rule
108109
public ExpectedException thrown = ExpectedException.none();
109110

111+
110112
@Test
111113
public void testUnreferencedSingletonWasInstantiated() {
112114
KnowsIfInstantiated.clearInstantiationRecord();
@@ -2748,6 +2750,7 @@ public String getUserName() {
27482750
}
27492751
}
27502752

2753+
27512754
@SuppressWarnings("unused")
27522755
private static class KnowsIfInstantiated {
27532756

spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<util:property-path id="name" path="
1616
configuredBean.
1717
name
18-
"/>
18+
"/>
1919

2020
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
2121
<property name="name">

spring-core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
import org.springframework.util.ObjectUtils;
2828

2929
/**
30-
* Converts an Array to another Array. First adapts the source array to a List, then
31-
* delegates to {@link CollectionToArrayConverter} to perform the target array conversion.
30+
* Converts an array to another array. First adapts the source array to a List,
31+
* then delegates to {@link CollectionToArrayConverter} to perform the target
32+
* array conversion.
3233
*
3334
* @author Keith Donald
3435
* @author Phillip Webb

spring-core/src/main/java/org/springframework/core/convert/support/ArrayToCollectionConverter.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -27,23 +27,27 @@
2727
import org.springframework.core.convert.converter.ConditionalGenericConverter;
2828

2929
/**
30-
* Converts an Array to a Collection.
30+
* Converts an array to a Collection.
3131
*
32-
* <p>First, creates a new Collection of the requested targetType.
32+
* <p>First, creates a new Collection of the requested target type.
3333
* Then adds each array element to the target collection.
34-
* Will perform an element conversion from the source component type to the collection's parameterized type if necessary.
34+
* Will perform an element conversion from the source component type
35+
* to the collection's parameterized type if necessary.
3536
*
3637
* @author Keith Donald
38+
* @author Juergen Hoeller
3739
* @since 3.0
3840
*/
3941
final class ArrayToCollectionConverter implements ConditionalGenericConverter {
4042

4143
private final ConversionService conversionService;
4244

45+
4346
public ArrayToCollectionConverter(ConversionService conversionService) {
4447
this.conversionService = conversionService;
4548
}
4649

50+
4751
@Override
4852
public Set<ConvertiblePair> getConvertibleTypes() {
4953
return Collections.singleton(new ConvertiblePair(Object[].class, Collection.class));
@@ -60,9 +64,12 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
6064
if (source == null) {
6165
return null;
6266
}
67+
6368
int length = Array.getLength(source);
69+
TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
6470
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), length);
65-
if (targetType.getElementTypeDescriptor() == null) {
71+
72+
if (elementDesc == null) {
6673
for (int i = 0; i < length; i++) {
6774
Object sourceElement = Array.get(source, i);
6875
target.add(sourceElement);
@@ -72,7 +79,7 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
7279
for (int i = 0; i < length; i++) {
7380
Object sourceElement = Array.get(source, i);
7481
Object targetElement = this.conversionService.convert(sourceElement,
75-
sourceType.elementTypeDescriptor(sourceElement), targetType.getElementTypeDescriptor());
82+
sourceType.elementTypeDescriptor(sourceElement), elementDesc);
7683
target.add(targetElement);
7784
}
7885
}

spring-core/src/main/java/org/springframework/core/convert/support/ArrayToObjectConverter.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -25,7 +25,8 @@
2525
import org.springframework.core.convert.converter.ConditionalGenericConverter;
2626

2727
/**
28-
* Converts an Array to an Object by returning the first array element after converting it to the desired targetType.
28+
* Converts an array to an Object by returning the first array element
29+
* after converting it to the desired target type.
2930
*
3031
* @author Keith Donald
3132
* @since 3.0
@@ -34,10 +35,12 @@ final class ArrayToObjectConverter implements ConditionalGenericConverter {
3435

3536
private final ConversionService conversionService;
3637

38+
3739
public ArrayToObjectConverter(ConversionService conversionService) {
3840
this.conversionService = conversionService;
3941
}
4042

43+
4144
@Override
4245
public Set<ConvertiblePair> getConvertibleTypes() {
4346
return Collections.singleton(new ConvertiblePair(Object[].class, Object.class));

spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import org.springframework.util.ObjectUtils;
2727

2828
/**
29-
* Converts an Array to a comma-delimited String.
30-
* This implementation first adapts the source Array to a List,
31-
* then delegates to {@link CollectionToStringConverter} to perform the target String conversion.
29+
* Converts an array to a comma-delimited String. First adapts the source array
30+
* to a List, then delegates to {@link CollectionToStringConverter} to perform
31+
* the target String conversion.
3232
*
3333
* @author Keith Donald
3434
* @since 3.0

spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* map's parameterized types K,V if necessary.
3737
*
3838
* @author Keith Donald
39+
* @author Juergen Hoeller
3940
* @since 3.0
4041
*/
4142
final class MapToMapConverter implements ConditionalGenericConverter {
@@ -64,17 +65,22 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
6465
if (source == null) {
6566
return null;
6667
}
67-
boolean copyRequired = !targetType.getType().isInstance(source);
6868
Map<Object, Object> sourceMap = (Map<Object, Object>) source;
69+
70+
// Shortcut if possible...
71+
boolean copyRequired = !targetType.getType().isInstance(source);
6972
if (!copyRequired && sourceMap.isEmpty()) {
7073
return sourceMap;
7174
}
75+
TypeDescriptor keyDesc = targetType.getMapKeyTypeDescriptor();
76+
TypeDescriptor valueDesc = targetType.getMapValueTypeDescriptor();
77+
7278
List<MapEntry> targetEntries = new ArrayList<MapEntry>(sourceMap.size());
7379
for (Map.Entry<Object, Object> entry : sourceMap.entrySet()) {
7480
Object sourceKey = entry.getKey();
7581
Object sourceValue = entry.getValue();
76-
Object targetKey = convertKey(sourceKey, sourceType, targetType.getMapKeyTypeDescriptor());
77-
Object targetValue = convertValue(sourceValue, sourceType, targetType.getMapValueTypeDescriptor());
82+
Object targetKey = convertKey(sourceKey, sourceType, keyDesc);
83+
Object targetValue = convertValue(sourceValue, sourceType, valueDesc);
7884
targetEntries.add(new MapEntry(targetKey, targetValue));
7985
if (sourceKey != targetKey || sourceValue != targetValue) {
8086
copyRequired = true;
@@ -83,6 +89,7 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
8389
if (!copyRequired) {
8490
return sourceMap;
8591
}
92+
8693
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
8794
for (MapEntry entry : targetEntries) {
8895
entry.addToMap(targetMap);

spring-core/src/main/java/org/springframework/core/convert/support/ObjectToArrayConverter.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -25,8 +25,8 @@
2525
import org.springframework.core.convert.converter.ConditionalGenericConverter;
2626

2727
/**
28-
* Converts an Object to a single-element Array containing the Object.
29-
* Will convert the Object to the target Array's component type if necessary.
28+
* Converts an Object to a single-element array containing the Object.
29+
* Will convert the Object to the target array's component type if necessary.
3030
*
3131
* @author Keith Donald
3232
* @since 3.0
@@ -35,10 +35,12 @@ final class ObjectToArrayConverter implements ConditionalGenericConverter {
3535

3636
private final ConversionService conversionService;
3737

38+
3839
public ObjectToArrayConverter(ConversionService conversionService) {
3940
this.conversionService = conversionService;
4041
}
4142

43+
4244
@Override
4345
public Set<ConvertiblePair> getConvertibleTypes() {
4446
return Collections.singleton(new ConvertiblePair(Object.class, Object[].class));

spring-core/src/main/java/org/springframework/core/convert/support/ObjectToCollectionConverter.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -37,10 +37,12 @@ final class ObjectToCollectionConverter implements ConditionalGenericConverter {
3737

3838
private final ConversionService conversionService;
3939

40+
4041
public ObjectToCollectionConverter(ConversionService conversionService) {
4142
this.conversionService = conversionService;
4243
}
4344

45+
4446
@Override
4547
public Set<ConvertiblePair> getConvertibleTypes() {
4648
return Collections.singleton(new ConvertiblePair(Object.class, Collection.class));
@@ -56,12 +58,15 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
5658
if (source == null) {
5759
return null;
5860
}
61+
62+
TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
5963
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), 1);
60-
if (targetType.getElementTypeDescriptor() == null || targetType.getElementTypeDescriptor().isCollection()) {
64+
65+
if (elementDesc == null || elementDesc.isCollection()) {
6166
target.add(source);
6267
}
6368
else {
64-
Object singleElement = this.conversionService.convert(source, sourceType, targetType.getElementTypeDescriptor());
69+
Object singleElement = this.conversionService.convert(source, sourceType, elementDesc);
6570
target.add(singleElement);
6671
}
6772
return target;

0 commit comments

Comments
 (0)