Polishing

This commit is contained in:
Juergen Hoeller 2020-05-14 00:23:20 +02:00
parent 8212aaf3bb
commit fe33822fa7
8 changed files with 34 additions and 30 deletions

View File

@ -150,7 +150,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
/** String resolvers to apply e.g. to annotation attribute values. */ /** String resolvers to apply e.g. to annotation attribute values. */
private final List<StringValueResolver> embeddedValueResolvers = new CopyOnWriteArrayList<>(); private final List<StringValueResolver> embeddedValueResolvers = new CopyOnWriteArrayList<>();
/** BeanPostProcessors to apply in createBean. */ /** BeanPostProcessors to apply. */
private final List<BeanPostProcessor> beanPostProcessors = new CopyOnWriteArrayList<>(); private final List<BeanPostProcessor> beanPostProcessors = new CopyOnWriteArrayList<>();
/** Indicates whether any InstantiationAwareBeanPostProcessors have been registered. */ /** Indicates whether any InstantiationAwareBeanPostProcessors have been registered. */
@ -948,7 +948,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
/** /**
* Return whether this factory holds a InstantiationAwareBeanPostProcessor * Return whether this factory holds a InstantiationAwareBeanPostProcessor
* that will get applied to singleton beans on shutdown. * that will get applied to singleton beans on creation.
* @see #addBeanPostProcessor * @see #addBeanPostProcessor
* @see org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor * @see org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 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.
@ -50,7 +50,7 @@ import org.springframework.validation.annotation.Validated;
* at the type level of the containing target class, applying to all public service methods * at the type level of the containing target class, applying to all public service methods
* of that class. By default, JSR-303 will validate against its default group only. * of that class. By default, JSR-303 will validate against its default group only.
* *
* <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider. * <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1+ provider.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
@ -87,7 +87,6 @@ public class MethodValidationInterceptor implements MethodInterceptor {
@Override @Override
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation invocation) throws Throwable { public Object invoke(MethodInvocation invocation) throws Throwable {
// Avoid Validator invocation on FactoryBean.getObjectType/isSingleton // Avoid Validator invocation on FactoryBean.getObjectType/isSingleton
if (isFactoryBeanMetadataMethod(invocation.getMethod())) { if (isFactoryBeanMetadataMethod(invocation.getMethod())) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 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.
@ -50,7 +50,7 @@ import org.springframework.validation.annotation.Validated;
* inline constraint annotations. Validation groups can be specified through {@code @Validated} * inline constraint annotations. Validation groups can be specified through {@code @Validated}
* as well. By default, JSR-303 will validate against its default group only. * as well. By default, JSR-303 will validate against its default group only.
* *
* <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider. * <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1+ provider.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 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.
@ -38,6 +38,7 @@ import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent; import javax.xml.stream.events.XMLEvent;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2; import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
@ -163,9 +164,11 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
this.encoding = startDocument.getCharacterEncodingScheme(); this.encoding = startDocument.getCharacterEncodingScheme();
} }
} }
if (getContentHandler() != null) {
ContentHandler contentHandler = getContentHandler();
if (contentHandler != null) {
final Location location = event.getLocation(); final Location location = event.getLocation();
getContentHandler().setDocumentLocator(new Locator2() { contentHandler.setDocumentLocator(new Locator2() {
@Override @Override
public int getColumnNumber() { public int getColumnNumber() {
return (location != null ? location.getColumnNumber() : -1); return (location != null ? location.getColumnNumber() : -1);
@ -194,7 +197,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
return encoding; return encoding;
} }
}); });
getContentHandler().startDocument(); contentHandler.startDocument();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 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.
@ -23,6 +23,7 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamReader;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2; import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
@ -139,9 +140,11 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
} }
this.encoding = this.reader.getCharacterEncodingScheme(); this.encoding = this.reader.getCharacterEncodingScheme();
} }
if (getContentHandler() != null) {
ContentHandler contentHandler = getContentHandler();
if (contentHandler != null) {
final Location location = this.reader.getLocation(); final Location location = this.reader.getLocation();
getContentHandler().setDocumentLocator(new Locator2() { contentHandler.setDocumentLocator(new Locator2() {
@Override @Override
public int getColumnNumber() { public int getColumnNumber() {
return (location != null ? location.getColumnNumber() : -1); return (location != null ? location.getColumnNumber() : -1);
@ -170,7 +173,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
return encoding; return encoding;
} }
}); });
getContentHandler().startDocument(); contentHandler.startDocument();
if (this.reader.standaloneSet()) { if (this.reader.standaloneSet()) {
setStandalone(this.reader.isStandalone()); setStandalone(this.reader.isStandalone());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 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.
@ -415,8 +415,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable); TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable);
this.tableParameterMetaData.add(meta); this.tableParameterMetaData.add(meta);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Retrieved meta-data: " + meta.getParameterName() + " " + logger.debug("Retrieved meta-data: '" + meta.getParameterName() + "', sqlType=" +
meta.getSqlType() + " " + meta.isNullable()); meta.getSqlType() + ", nullable=" + meta.isNullable());
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 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.
@ -284,8 +284,7 @@ public class DataSourceTransactionManagerTests {
boolean condition1 = !TransactionSynchronizationManager.isSynchronizationActive(); boolean condition1 = !TransactionSynchronizationManager.isSynchronizationActive();
assertThat(condition1).as("Synchronization not active").isTrue(); assertThat(condition1).as("Synchronization not active").isTrue();
ConnectionHolder conHolder = new ConnectionHolder(con); ConnectionHolder conHolder = new ConnectionHolder(con, true);
conHolder.setTransactionActive(true);
TransactionSynchronizationManager.bindResource(ds, conHolder); TransactionSynchronizationManager.bindResource(ds, conHolder);
final RuntimeException ex = new RuntimeException("Application exception"); final RuntimeException ex = new RuntimeException("Application exception");
try { try {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 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.
@ -45,14 +45,14 @@ public class SQLErrorCodeSQLExceptionTranslatorTests {
private static SQLErrorCodes ERROR_CODES = new SQLErrorCodes(); private static SQLErrorCodes ERROR_CODES = new SQLErrorCodes();
static { static {
ERROR_CODES.setBadSqlGrammarCodes(new String[] { "1", "2" }); ERROR_CODES.setBadSqlGrammarCodes("1", "2");
ERROR_CODES.setInvalidResultSetAccessCodes(new String[] { "3", "4" }); ERROR_CODES.setInvalidResultSetAccessCodes("3", "4");
ERROR_CODES.setDuplicateKeyCodes(new String[] {"10"}); ERROR_CODES.setDuplicateKeyCodes("10");
ERROR_CODES.setDataAccessResourceFailureCodes(new String[] { "5" }); ERROR_CODES.setDataAccessResourceFailureCodes("5");
ERROR_CODES.setDataIntegrityViolationCodes(new String[] { "6" }); ERROR_CODES.setDataIntegrityViolationCodes("6");
ERROR_CODES.setCannotAcquireLockCodes(new String[] { "7" }); ERROR_CODES.setCannotAcquireLockCodes("7");
ERROR_CODES.setDeadlockLoserCodes(new String[] { "8" }); ERROR_CODES.setDeadlockLoserCodes("8");
ERROR_CODES.setCannotSerializeTransactionCodes(new String[] { "9" }); ERROR_CODES.setCannotSerializeTransactionCodes("9");
} }