Skip to content

Commit 761bd9f

Browse files
committed
Merge branch '3.2.x'
* 3.2.x: Update javadoc external links JdbcTemplate etc Removed unnecessary default value of LifecycleGroup.lifecycleBeans Introduced public ArgumentPreparedStatementSetter and ArgumentTypePreparedStatementSetter classes Defensively uses JDBC 3.0 getParameterType call for Oracle driver compatibility Preparations for 3.2.3 Fixed ReflectiveMethodResolver to avoid potential UnsupportedOperationException on sort Fixed Jaxb2Marshaller's partial unmarshalling feature to consistently apply to all sources Update copyright year in reference documentation Conflicts: build.gradle gradle.properties spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentPreparedStatementSetter.java spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentTypePreparedStatementSetter.java
2 parents cf687fc + 39d043d commit 761bd9f

File tree

9 files changed

+66
-56
lines changed

9 files changed

+66
-56
lines changed

spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java

Lines changed: 5 additions & 5 deletions
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-2013 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.
@@ -302,16 +302,16 @@ private class LifecycleGroup {
302302

303303
private final List<LifecycleGroupMember> members = new ArrayList<LifecycleGroupMember>();
304304

305-
private Map<String, ? extends Lifecycle> lifecycleBeans = getLifecycleBeans();
306-
307-
private volatile int smartMemberCount;
308-
309305
private final int phase;
310306

311307
private final long timeout;
312308

309+
private final Map<String, ? extends Lifecycle> lifecycleBeans;
310+
313311
private final boolean autoStartupOnly;
314312

313+
private volatile int smartMemberCount;
314+
315315
public LifecycleGroup(int phase, long timeout, Map<String, ? extends Lifecycle> lifecycleBeans, boolean autoStartupOnly) {
316316
this.phase = phase;
317317
this.timeout = timeout;

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ public MethodExecutor resolve(EvaluationContext context, Object targetObject, St
103103
}
104104

105105
// Sort methods into a sensible order
106-
Collections.sort(methods, new Comparator<Method>() {
107-
public int compare(Method m1, Method m2) {
108-
int m1pl = m1.getParameterTypes().length;
109-
int m2pl = m2.getParameterTypes().length;
110-
return (new Integer(m1pl)).compareTo(m2pl);
111-
}
112-
});
106+
if (methods.size() > 1) {
107+
Collections.sort(methods, new Comparator<Method>() {
108+
public int compare(Method m1, Method m2) {
109+
int m1pl = m1.getParameterTypes().length;
110+
int m2pl = m2.getParameterTypes().length;
111+
return (new Integer(m1pl)).compareTo(m2pl);
112+
}
113+
});
114+
}
113115

114116
// Resolve any bridge methods
115117
for (int i = 0; i < methods.size(); i++) {

spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgPreparedStatementSetter.java renamed to spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentPreparedStatementSetter.java

Lines changed: 5 additions & 5 deletions
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-2013 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.
@@ -20,12 +20,12 @@
2020
import java.sql.SQLException;
2121

2222
/**
23-
* Simple adapter for PreparedStatementSetter that applies
24-
* a given array of arguments.
23+
* Simple adapter for {@link PreparedStatementSetter} that applies a given array of arguments.
2524
*
2625
* @author Juergen Hoeller
26+
* @since 3.2.3
2727
*/
28-
class ArgPreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
28+
public class ArgumentPreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
2929

3030
private final Object[] args;
3131

@@ -34,7 +34,7 @@ class ArgPreparedStatementSetter implements PreparedStatementSetter, ParameterDi
3434
* Create a new ArgPreparedStatementSetter for the given arguments.
3535
* @param args the arguments to set
3636
*/
37-
public ArgPreparedStatementSetter(Object[] args) {
37+
public ArgumentPreparedStatementSetter(Object[] args) {
3838
this.args = args;
3939
}
4040

spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgTypePreparedStatementSetter.java renamed to spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentTypePreparedStatementSetter.java

Lines changed: 9 additions & 10 deletions
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-2013 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.
@@ -20,17 +20,17 @@
2020
import java.sql.SQLException;
2121
import java.sql.Types;
2222
import java.util.Collection;
23-
import java.util.Iterator;
2423

2524
import org.springframework.dao.InvalidDataAccessApiUsageException;
2625

2726
/**
28-
* Simple adapter for PreparedStatementSetter that applies
27+
* Simple adapter for {@link PreparedStatementSetter} that applies
2928
* given arrays of arguments and JDBC argument types.
3029
*
3130
* @author Juergen Hoeller
31+
* @since 3.2.3
3232
*/
33-
class ArgTypePreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
33+
public class ArgumentTypePreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
3434

3535
private final Object[] args;
3636

@@ -42,7 +42,7 @@ class ArgTypePreparedStatementSetter implements PreparedStatementSetter, Paramet
4242
* @param args the arguments to set
4343
* @param argTypes the corresponding SQL types of the arguments
4444
*/
45-
public ArgTypePreparedStatementSetter(Object[] args, int[] argTypes) {
45+
public ArgumentTypePreparedStatementSetter(Object[] args, int[] argTypes) {
4646
if ((args != null && argTypes == null) || (args == null && argTypes != null) ||
4747
(args != null && args.length != argTypes.length)) {
4848
throw new InvalidDataAccessApiUsageException("args and argTypes parameters must match");
@@ -59,12 +59,10 @@ public void setValues(PreparedStatement ps) throws SQLException {
5959
Object arg = this.args[i];
6060
if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
6161
Collection entries = (Collection) arg;
62-
for (Iterator it = entries.iterator(); it.hasNext();) {
63-
Object entry = it.next();
62+
for (Object entry : entries) {
6463
if (entry instanceof Object[]) {
65-
Object[] valueArray = ((Object[])entry);
66-
for (int k = 0; k < valueArray.length; k++) {
67-
Object argValue = valueArray[k];
64+
Object[] valueArray = ((Object[]) entry);
65+
for (Object argValue : valueArray) {
6866
doSetValue(ps, parameterPosition, this.argTypes[i], argValue);
6967
parameterPosition++;
7068
}
@@ -94,6 +92,7 @@ public void setValues(PreparedStatement ps) throws SQLException {
9492
*/
9593
protected void doSetValue(PreparedStatement ps, int parameterPosition, int argType, Object argValue)
9694
throws SQLException {
95+
9796
StatementCreatorUtils.setParameterValue(ps, parameterPosition, argType, argValue);
9897
}
9998

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,24 +1291,26 @@ protected void applyStatementSettings(Statement stmt) throws SQLException {
12911291
}
12921292

12931293
/**
1294-
* Create a new ArgPreparedStatementSetter using the args passed in. This method allows the
1295-
* creation to be overridden by sub-classes.
1294+
* Create a new arg-based PreparedStatementSetter using the args passed in.
1295+
* <p>By default, we'll create an {@link ArgumentPreparedStatementSetter}.
1296+
* This method allows for the creation to be overridden by subclasses.
12961297
* @param args object array with arguments
1297-
* @return the new PreparedStatementSetter
1298+
* @return the new PreparedStatementSetter to use
12981299
*/
12991300
protected PreparedStatementSetter newArgPreparedStatementSetter(Object[] args) {
1300-
return new ArgPreparedStatementSetter(args);
1301+
return new ArgumentPreparedStatementSetter(args);
13011302
}
13021303

13031304
/**
1304-
* Create a new ArgTypePreparedStatementSetter using the args and argTypes passed in.
1305-
* This method allows the creation to be overridden by sub-classes.
1305+
* Create a new arg-type-based PreparedStatementSetter using the args and types passed in.
1306+
* <p>By default, we'll create an {@link ArgumentTypePreparedStatementSetter}.
1307+
* This method allows for the creation to be overridden by subclasses.
13061308
* @param args object array with arguments
1307-
* @param argTypes int array of SQLTypes for arguments
1308-
* @return the new PreparedStatementSetter
1309+
* @param argTypes int array of SQLTypes for the associated arguments
1310+
* @return the new PreparedStatementSetter to use
13091311
*/
13101312
protected PreparedStatementSetter newArgTypePreparedStatementSetter(Object[] args, int[] argTypes) {
1311-
return new ArgTypePreparedStatementSetter(args, argTypes);
1313+
return new ArgumentTypePreparedStatementSetter(args, argTypes);
13121314
}
13131315

13141316
/**

spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.sql.Blob;
2323
import java.sql.Clob;
2424
import java.sql.DatabaseMetaData;
25-
import java.sql.ParameterMetaData;
2625
import java.sql.PreparedStatement;
2726
import java.sql.SQLException;
2827
import java.sql.Types;
@@ -229,18 +228,13 @@ private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, S
229228
boolean useSetObject = false;
230229
sqlType = Types.NULL;
231230
try {
232-
ParameterMetaData pmd = null;
231+
sqlType = ps.getParameterMetaData().getParameterType(paramIndex);
232+
}
233+
catch (Throwable ex) {
234+
logger.debug("JDBC 3.0 getParameterType call not supported", ex);
235+
// JDBC driver not compliant with JDBC 3.0
236+
// -> proceed with database-specific checks
233237
try {
234-
pmd = ps.getParameterMetaData();
235-
}
236-
catch (Throwable ex) {
237-
// JDBC driver not compliant with JDBC 3.0
238-
// -> proceed with database-specific checks
239-
}
240-
if (pmd != null) {
241-
sqlType = pmd.getParameterType(paramIndex);
242-
}
243-
else {
244238
DatabaseMetaData dbmd = ps.getConnection().getMetaData();
245239
String databaseProductName = dbmd.getDatabaseProductName();
246240
String jdbcDriverName = dbmd.getDriverName();
@@ -255,9 +249,9 @@ else if (databaseProductName.startsWith("DB2") ||
255249
sqlType = Types.VARCHAR;
256250
}
257251
}
258-
}
259-
catch (Throwable ex) {
260-
logger.debug("Could not check database or driver name", ex);
252+
catch (Throwable ex2) {
253+
logger.debug("Could not check database or driver name", ex2);
254+
}
261255
}
262256
if (useSetObject) {
263257
ps.setObject(paramIndex, null);

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMa
720720
return unmarshalStaxSource(unmarshaller, source);
721721
}
722722
else if (this.mappedClass != null) {
723-
return unmarshaller.unmarshal(source, this.mappedClass);
723+
return unmarshaller.unmarshal(source, this.mappedClass).getValue();
724724
}
725725
else {
726726
return unmarshaller.unmarshal(source);
@@ -734,12 +734,16 @@ else if (this.mappedClass != null) {
734734
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
735735
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
736736
if (streamReader != null) {
737-
return jaxbUnmarshaller.unmarshal(streamReader);
737+
return (this.mappedClass != null ?
738+
jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
739+
jaxbUnmarshaller.unmarshal(streamReader));
738740
}
739741
else {
740742
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
741743
if (eventReader != null) {
742-
return jaxbUnmarshaller.unmarshal(eventReader);
744+
return (this.mappedClass != null ?
745+
jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
746+
jaxbUnmarshaller.unmarshal(eventReader));
743747
}
744748
else {
745749
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");

src/dist/changelog.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ SPRING FRAMEWORK CHANGELOG
33
http://www.springsource.org
44

55

6+
Changes in version 3.2.3 (2013-05-02)
7+
-------------------------------------
8+
9+
* fixed ReflectiveMethodResolver to avoid potential UnsupportedOperationException on sort (SPR-10392)
10+
* fixed Jaxb2Marshaller's partial unmarshalling feature to consistently apply to all sources (SPR-10282)
11+
* JdbcTemplate defensively uses JDBC 3.0 getParameterType call for Oracle driver compatibility (SPR-10385)
12+
* introduced public ArgumentPreparedStatementSetter and ArgumentTypePreparedStatementSetter classes (SPR-10375)
13+
14+
615
Changes in version 3.2.2 (2013-03-14)
7-
--------------------------------------
16+
-------------------------------------
817

918
* official support for Hibernate 4.2 (SPR-10255)
1019
* fixed missing inter-dependencies in module POMs (SPR-10218)

src/reference/docbook/index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
</authorgroup>
161161

162162
<copyright>
163-
<year>2004-2012</year>
163+
<year>2004-2013</year>
164164
</copyright>
165165

166166
<legalnotice>

0 commit comments

Comments
 (0)