Browse Source

Polishing

(cherry picked from commit ce4e795)
pull/806/head
Juergen Hoeller 11 years ago
parent
commit
e5ccdfb029
  1. 5
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
  2. 4
      spring-context/src/main/java/org/springframework/cache/Cache.java
  3. 14
      spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java
  4. 5
      spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java
  5. 25
      spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
  6. 17
      spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java
  7. 6
      spring-core/src/main/java/org/springframework/util/ReflectionUtils.java
  8. 6
      spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java
  9. 26
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java
  10. 28
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java
  11. 21
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
  12. 5
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java
  13. 4
      spring-web/src/main/java/org/springframework/web/multipart/MaxUploadSizeExceededException.java
  14. 31
      spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java

5
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -200,8 +200,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut @@ -200,8 +200,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
pointcutParameters[i] = parser.createPointcutParameter(
this.pointcutParameterNames[i], this.pointcutParameterTypes[i]);
}
return parser.parsePointcutExpression(
replaceBooleanOperators(getExpression()),
return parser.parsePointcutExpression(replaceBooleanOperators(getExpression()),
this.pointcutDeclarationScope, pointcutParameters);
}

4
spring-context/src/main/java/org/springframework/cache/Cache.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
package org.springframework.cache;
/**
* Interface that defines the common cache operations.
* Interface that defines common cache operations.
*
* <b>Note:</b> Due to the generic use of caching, it is recommended that
* implementations allow storage of <tt>null</tt> values (for example to

14
spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -151,13 +151,12 @@ public @interface EnableCaching { @@ -151,13 +151,12 @@ public @interface EnableCaching {
* Indicate whether subclass-based (CGLIB) proxies are to be created as opposed
* to standard Java interface-based proxies. The default is {@code false}. <strong>
* Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>.
*
* <p>Note that setting this attribute to {@code true} will affect <em>all</em>
* Spring-managed beans requiring proxying, not just those marked with
* {@code @Cacheable}. For example, other beans marked with Spring's
* {@code @Transactional} annotation will be upgraded to subclass proxying at the same
* time. This approach has no negative impact in practice unless one is explicitly
* expecting one type of proxy vs another, e.g. in tests.
* Spring-managed beans requiring proxying, not just those marked with {@code @Cacheable}.
* For example, other beans marked with Spring's {@code @Transactional} annotation will
* be upgraded to subclass proxying at the same time. This approach has no negative
* impact in practice unless one is explicitly expecting one type of proxy vs another,
* e.g. in tests.
*/
boolean proxyTargetClass() default false;
@ -174,4 +173,5 @@ public @interface EnableCaching { @@ -174,4 +173,5 @@ public @interface EnableCaching {
* The default is {@link Ordered#LOWEST_PRECEDENCE}.
*/
int order() default Ordered.LOWEST_PRECEDENCE;
}

5
spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import groovy.lang.MetaClass; @@ -24,7 +24,6 @@ import groovy.lang.MetaClass;
import groovy.lang.Script;
import org.codehaus.groovy.control.CompilationFailedException;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@ -99,7 +98,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea @@ -99,7 +98,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
}
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableListableBeanFactory) {
((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
}

25
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -94,7 +94,7 @@ import org.springframework.util.StringUtils; @@ -94,7 +94,7 @@ import org.springframework.util.StringUtils;
* &lt;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt;
*
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"&gt;
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"&gt;
* &lt;constructor-arg value="classpath:mypackage/Messenger.groovy"/&gt;
* &lt;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt;</pre>
@ -325,7 +325,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces @@ -325,7 +325,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
throw new BeanDefinitionValidationException(
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" +
language + "'");
language + "'");
}
ts.setRefreshCheckDelay(refreshCheckDelay);
return createRefreshableProxy(ts, interfaces, proxyTargetClass);
@ -346,17 +346,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces @@ -346,17 +346,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
* @param scriptedObjectBeanName the name of the internal scripted object bean
*/
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a prototype.
synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory = this.scriptBeanFactory
.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
scriptFactory.getScriptSourceLocator());
this.scriptBeanFactory.registerBeanDefinition(
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory =
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource =
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces;
@ -365,8 +364,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces @@ -365,8 +364,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
scriptedInterfaces);
BeanDefinition objectBd = createScriptedObjectBeanDefinition(
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
@ -569,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces @@ -569,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
proxyFactory.setInterfaces(interfaces);
if (proxyTargetClass) {
classLoader = null; // force use of Class.getClassLoader()
proxyFactory.setProxyTargetClass(proxyTargetClass);
proxyFactory.setProxyTargetClass(true);
}
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);

17
spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import javax.inject.Inject; @@ -24,7 +24,6 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Qualifier;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.scope.ScopedProxyUtils;
@ -36,6 +35,8 @@ import org.springframework.beans.factory.config.ConstructorArgumentValues; @@ -36,6 +35,8 @@ import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.support.GenericApplicationContext;
import static org.junit.Assert.*;
/**
* Integration tests for handling JSR-303 {@link javax.inject.Qualifier} annotations.
*
@ -666,27 +667,27 @@ public class InjectAnnotationAutowireContextTests { @@ -666,27 +667,27 @@ public class InjectAnnotationAutowireContextTests {
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifier {
public @interface TestQualifier {
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifierWithDefaultValue {
public @interface TestQualifierWithDefaultValue {
public abstract String value() default "default";
String value() default "default";
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifierWithMultipleAttributes {
public @interface TestQualifierWithMultipleAttributes {
public abstract String value() default "default";
String value() default "default";
public abstract int number();
int number();
}
}

6
spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

@ -91,7 +91,8 @@ public abstract class ReflectionUtils { @@ -91,7 +91,8 @@ public abstract class ReflectionUtils {
while (!Object.class.equals(searchType) && searchType != null) {
Field[] fields = searchType.getDeclaredFields();
for (Field field : fields) {
if ((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) {
if ((name == null || name.equals(field.getName())) &&
(type == null || type.equals(field.getType()))) {
return field;
}
}
@ -424,7 +425,8 @@ public abstract class ReflectionUtils { @@ -424,7 +425,8 @@ public abstract class ReflectionUtils {
* @see java.lang.reflect.Field#setAccessible
*/
public static void makeAccessible(Field field) {
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
if ((!Modifier.isPublic(field.getModifiers()) ||
!Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
field.setAccessible(true);
}

6
spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -165,11 +165,11 @@ public class GenericTypeResolverTests { @@ -165,11 +165,11 @@ public class GenericTypeResolverTests {
public void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception {
// SPR-11044
Class<?> resolved = GenericTypeResolver.resolveReturnType(
WithArrayBase.class.getDeclaredMethod("array", Object[].class),
WithArray.class);
WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class);
assertThat(resolved, equalTo((Class) Object[].class));
}
public interface MyInterfaceType<T> {
}

26
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import java.sql.DatabaseMetaData; @@ -20,7 +20,6 @@ import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@ -32,16 +31,14 @@ import org.springframework.jdbc.support.JdbcUtils; @@ -32,16 +31,14 @@ import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.MetaDataAccessException;
/**
* Factory used to create a {@link CallMetaDataProvider} implementation based on the type of databse being used.
* Factory used to create a {@link CallMetaDataProvider} implementation
* based on the type of database being used.
*
* @author Thomas Risberg
* @since 2.5
*/
public class CallMetaDataProviderFactory {
/** Logger */
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
/** List of supported database products for procedure calls */
public static final List<String> supportedDatabaseProductsForProcedures = Arrays.asList(
"Apache Derby",
@ -52,6 +49,7 @@ public class CallMetaDataProviderFactory { @@ -52,6 +49,7 @@ public class CallMetaDataProviderFactory {
"PostgreSQL",
"Sybase"
);
/** List of supported database products for function calls */
public static final List<String> supportedDatabaseProductsForFunctions = Arrays.asList(
"MySQL",
@ -60,10 +58,13 @@ public class CallMetaDataProviderFactory { @@ -60,10 +58,13 @@ public class CallMetaDataProviderFactory {
"PostgreSQL"
);
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
/**
* Create a CallMetaDataProvider based on the database metedata
* @param dataSource used to retrieve metedata
* @param context the class that holds configuration and metedata
* Create a CallMetaDataProvider based on the database metadata
* @param dataSource used to retrieve metadata
* @param context the class that holds configuration and metadata
* @return instance of the CallMetaDataProvider implementation to be used
*/
static public CallMetaDataProvider createMetaDataProvider(DataSource dataSource, final CallMetaDataContext context) {
@ -124,17 +125,16 @@ public class CallMetaDataProviderFactory { @@ -124,17 +125,16 @@ public class CallMetaDataProviderFactory {
}
provider.initializeWithMetaData(databaseMetaData);
if (accessProcedureColumnMetaData) {
provider.initializeWithProcedureColumnMetaData(
databaseMetaData, context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
provider.initializeWithProcedureColumnMetaData(databaseMetaData,
context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
}
return provider;
}
});
}
catch (MetaDataAccessException ex) {
throw new DataAccessResourceFailureException("Error retreiving database metadata", ex);
throw new DataAccessResourceFailureException("Error retrieving database metadata", ex);
}
}
}

28
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { @@ -70,7 +70,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
Arrays.asList("Apache Derby", "HSQL Database Engine");
/** Collection of TableParameterMetaData objects */
private List<TableParameterMetaData> insertParameterMetaData = new ArrayList<TableParameterMetaData>();
private List<TableParameterMetaData> tableParameterMetaData = new ArrayList<TableParameterMetaData>();
/** NativeJdbcExtractor that can be used to retrieve the native connection */
private NativeJdbcExtractor nativeJdbcExtractor;
@ -107,7 +107,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { @@ -107,7 +107,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
public List<TableParameterMetaData> getTableParameterMetaData() {
return this.insertParameterMetaData;
return this.tableParameterMetaData;
}
public boolean isGetGeneratedKeysSupported() {
@ -362,17 +362,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { @@ -362,17 +362,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
try {
tableColumns = databaseMetaData.getColumns(
metaDataCatalogName,
metaDataSchemaName,
metaDataTableName,
null);
metaDataCatalogName, metaDataSchemaName, metaDataTableName, null);
while (tableColumns.next()) {
String columnName = tableColumns.getString("COLUMN_NAME");
int dataType = tableColumns.getInt("DATA_TYPE");
if (dataType == Types.DECIMAL) {
String typeName = tableColumns.getString("TYPE_NAME");
int decimalDigits = tableColumns.getInt("DECIMAL_DIGITS");
// override a DECIMAL data type for no-decimal numerics
// Override a DECIMAL data type for no-decimal numerics
// (this is for better Oracle support where there have been issues
// using DECIMAL for certain inserts (see SPR-6912))
if ("NUMBER".equals(typeName) && decimalDigits == 0) {
@ -386,18 +383,11 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { @@ -386,18 +383,11 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
}
boolean nullable = tableColumns.getBoolean("NULLABLE");
TableParameterMetaData meta = new TableParameterMetaData(
columnName,
dataType,
nullable
);
this.insertParameterMetaData.add(meta);
TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable);
this.tableParameterMetaData.add(meta);
if (logger.isDebugEnabled()) {
logger.debug("Retrieved metadata: "
+ meta.getParameterName() +
" " + meta.getSqlType() +
" " + meta.isNullable()
);
logger.debug("Retrieved metadata: " + meta.getParameterName() +
" " + meta.getSqlType() + " " + meta.isNullable());
}
}
}

21
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -201,7 +201,8 @@ public class TableMetaDataContext { @@ -201,7 +201,8 @@ public class TableMetaDataContext {
* @param generatedKeyNames name of generated keys
*/
public void processMetaData(DataSource dataSource, List<String> declaredColumns, String[] generatedKeyNames) {
this.metaDataProvider = TableMetaDataProviderFactory.createMetaDataProvider(dataSource, this, this.nativeJdbcExtractor);
this.metaDataProvider =
TableMetaDataProviderFactory.createMetaDataProvider(dataSource, this, this.nativeJdbcExtractor);
this.tableColumns = reconcileColumnsToUse(declaredColumns, generatedKeyNames);
}
@ -298,14 +299,14 @@ public class TableMetaDataContext { @@ -298,14 +299,14 @@ public class TableMetaDataContext {
}
StringBuilder insertStatement = new StringBuilder();
insertStatement.append("INSERT INTO ");
if (this.getSchemaName() != null) {
insertStatement.append(this.getSchemaName());
if (getSchemaName() != null) {
insertStatement.append(getSchemaName());
insertStatement.append(".");
}
insertStatement.append(this.getTableName());
insertStatement.append(getTableName());
insertStatement.append(" (");
int columnCount = 0;
for (String columnName : this.getTableColumns()) {
for (String columnName : getTableColumns()) {
if (!keys.contains(columnName.toUpperCase())) {
columnCount++;
if (columnCount > 1) {
@ -318,11 +319,11 @@ public class TableMetaDataContext { @@ -318,11 +319,11 @@ public class TableMetaDataContext {
if (columnCount < 1) {
if (this.generatedKeyColumnsUsed) {
logger.info("Unable to locate non-key columns for table '" +
this.getTableName() + "' so an empty insert statement is generated");
getTableName() + "' so an empty insert statement is generated");
}
else {
throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
this.getTableName() + "' so an insert statement can't be generated");
getTableName() + "' so an insert statement can't be generated");
}
}
for (int i = 0; i < columnCount; i++) {
@ -340,14 +341,14 @@ public class TableMetaDataContext { @@ -340,14 +341,14 @@ public class TableMetaDataContext {
* @return the array of types to be used
*/
public int[] createInsertTypes() {
int[] types = new int[this.getTableColumns().size()];
int[] types = new int[getTableColumns().size()];
List<TableParameterMetaData> parameters = this.metaDataProvider.getTableParameterMetaData();
Map<String, TableParameterMetaData> parameterMap = new HashMap<String, TableParameterMetaData>(parameters.size());
for (TableParameterMetaData tpmd : parameters) {
parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd);
}
int typeIndx = 0;
for (String column : this.getTableColumns()) {
for (String column : getTableColumns()) {
if (column == null) {
types[typeIndx] = SqlTypeValue.TYPE_UNKNOWN;
}

5
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,7 +30,8 @@ import org.springframework.jdbc.support.MetaDataAccessException; @@ -30,7 +30,8 @@ import org.springframework.jdbc.support.MetaDataAccessException;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;
/**
* Factory used to create a {@link TableMetaDataProvider} implementation based on the type of databse being used.
* Factory used to create a {@link TableMetaDataProvider} implementation
* based on the type of database being used.
*
* @author Thomas Risberg
* @since 2.5

4
spring-web/src/main/java/org/springframework/web/multipart/MaxUploadSizeExceededException.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ public class MaxUploadSizeExceededException extends MultipartException { @@ -52,7 +52,7 @@ public class MaxUploadSizeExceededException extends MultipartException {
* Return the maximum upload size allowed.
*/
public long getMaxUploadSize() {
return maxUploadSize;
return this.maxUploadSize;
}
}

31
spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,20 +21,21 @@ import java.util.Arrays; @@ -21,20 +21,21 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.PropertyValues;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockMultipartFile;
import org.springframework.mock.web.test.MockMultipartHttpServletRequest;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.web.bind.ServletRequestParameterPropertyValues;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.multipart.support.StringMultipartFileEditor;
import static org.junit.Assert.*;
/**
* @author Juergen Hoeller
*/
@ -146,6 +147,28 @@ public class WebRequestDataBinderTests { @@ -146,6 +147,28 @@ public class WebRequestDataBinderTests {
assertFalse(target.isPostProcessed());
}
@Test
public void testFieldDefaultWithNestedProperty() throws Exception {
TestBean target = new TestBean();
target.setSpouse(new TestBean());
WebRequestDataBinder binder = new WebRequestDataBinder(target);
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("!spouse.postProcessed", "on");
request.addParameter("_spouse.postProcessed", "visible");
request.addParameter("spouse.postProcessed", "on");
binder.bind(new ServletWebRequest(request));
assertTrue(((TestBean) target.getSpouse()).isPostProcessed());
request.removeParameter("spouse.postProcessed");
binder.bind(new ServletWebRequest(request));
assertTrue(((TestBean) target.getSpouse()).isPostProcessed());
request.removeParameter("!spouse.postProcessed");
binder.bind(new ServletWebRequest(request));
assertFalse(((TestBean) target.getSpouse()).isPostProcessed());
}
@Test
public void testFieldDefaultNonBoolean() throws Exception {
TestBean target = new TestBean();

Loading…
Cancel
Save