Browse Source

Polishing

pull/1935/head
Juergen Hoeller 8 years ago
parent
commit
484addb4f8
  1. 4
      spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java
  2. 6
      spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java
  3. 4
      spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java
  4. 12
      spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java
  5. 9
      spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java
  6. 6
      spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java
  7. 6
      spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
  8. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java
  9. 13
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
  10. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java
  11. 6
      spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java
  12. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java
  13. 4
      spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java
  14. 19
      spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java
  15. 6
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java

4
spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -640,7 +640,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport @@ -640,7 +640,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
}
public String getBeanName() {
return beanName;
return this.beanName;
}
@Override

6
spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 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.
@ -74,8 +74,8 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac @@ -74,8 +74,8 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
* @param target the bean instance to destroy
*/
protected void destroyPrototypeInstance(Object target) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
if (logger.isDebugEnabled()) {
logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
}
if (getBeanFactory() instanceof ConfigurableBeanFactory) {
((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target);

4
spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -77,7 +77,7 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar { @@ -77,7 +77,7 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
}
}
}
if (!candidateFound) {
if (!candidateFound && logger.isWarnEnabled()) {
String name = getClass().getSimpleName();
logger.warn(String.format("%s was imported but no annotations were found " +
"having both 'mode' and 'proxyTargetClass' attributes of type " +

12
spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
@ -209,7 +209,9 @@ public class MBeanRegistrationSupport { @@ -209,7 +209,9 @@ public class MBeanRegistrationSupport {
registeredBean = this.server.registerMBean(mbean, objectName);
}
catch (InstanceNotFoundException ex2) {
logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
if (logger.isErrorEnabled()) {
logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
}
throw ex;
}
}
@ -239,9 +241,9 @@ public class MBeanRegistrationSupport { @@ -239,9 +241,9 @@ public class MBeanRegistrationSupport {
}
if (!snapshot.isEmpty()) {
logger.info("Unregistering JMX-exposed beans");
}
for (ObjectName objectName : snapshot) {
doUnregister(objectName);
for (ObjectName objectName : snapshot) {
doUnregister(objectName);
}
}
}

9
spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@ -436,8 +436,8 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing @@ -436,8 +436,8 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
}
catch (NotBoundException ex) {
if (logger.isWarnEnabled()) {
logger.warn("RMI service '" + this.serviceName + "' is not bound to registry"
+ (this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex);
logger.warn("RMI service '" + this.serviceName + "' is not bound to registry" +
(this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex);
}
}
finally {
@ -454,8 +454,9 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing @@ -454,8 +454,9 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
}
catch (NoSuchObjectException ex) {
if (logger.isWarnEnabled()) {
logger.warn("RMI object for service '" + this.serviceName + "' isn't exported anymore", ex);
logger.warn("RMI object for service '" + this.serviceName + "' is not exported anymore", ex);
}
}
}
}

6
spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2018 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.
@ -79,13 +79,13 @@ public abstract class RemoteInvocationBasedExporter extends RemoteExporter { @@ -79,13 +79,13 @@ public abstract class RemoteInvocationBasedExporter extends RemoteExporter {
}
catch (NoSuchMethodException ex) {
if (logger.isDebugEnabled()) {
logger.warn("Could not find target method for " + invocation, ex);
logger.debug("Could not find target method for " + invocation, ex);
}
throw ex;
}
catch (IllegalAccessException ex) {
if (logger.isDebugEnabled()) {
logger.warn("Could not access target method for " + invocation, ex);
logger.debug("Could not access target method for " + invocation, ex);
}
throw ex;
}

6
spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.core.env;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Map;
@ -249,6 +250,9 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { @@ -249,6 +250,9 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@Override
public void setActiveProfiles(String... profiles) {
Assert.notNull(profiles, "Profile array must not be null");
if (logger.isDebugEnabled()) {
logger.debug("Activating profiles " + Arrays.asList(profiles));
}
synchronized (this.activeProfiles) {
this.activeProfiles.clear();
for (String profile : profiles) {

4
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java

@ -496,7 +496,7 @@ public class CallMetaDataContext { @@ -496,7 +496,7 @@ public class CallMetaDataContext {
matchedParameters.put(parameterName,
SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
}
else {
else if (logger.isWarnEnabled()) {
logger.warn("Unable to locate the corresponding parameter value for '" +
parameterName + "' within the parameter values provided: " +
caseInsensitiveParameterNames.values());
@ -562,7 +562,7 @@ public class CallMetaDataContext { @@ -562,7 +562,7 @@ public class CallMetaDataContext {
for (String parameterName : callParameterNames.keySet()) {
String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
String callParameterName = callParameterNames.get(parameterNameToMatch.toLowerCase());
if (!matchedParameters.containsKey(callParameterName)) {
if (!matchedParameters.containsKey(callParameterName) && logger.isWarnEnabled()) {
logger.warn("Unable to locate the corresponding parameter value for '" + parameterName +
"' within the parameter values provided: " + inParameters.keySet());
}

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

@ -182,7 +182,7 @@ public class TableMetaDataContext { @@ -182,7 +182,7 @@ public class TableMetaDataContext {
if (generatedKeyNames.length > 0) {
this.generatedKeyColumnsUsed = true;
}
if (declaredColumns.size() > 0) {
if (!declaredColumns.isEmpty()) {
return new ArrayList<String>(declaredColumns);
}
Set<String> keys = new LinkedHashSet<String>(generatedKeyNames.length);
@ -255,7 +255,7 @@ public class TableMetaDataContext { @@ -255,7 +255,7 @@ public class TableMetaDataContext {
/**
* Build the insert string based on configuration and meta-data information
* Build the insert string based on configuration and meta-data information.
* @return the insert string to be used
*/
public String createInsertString(String... generatedKeyNames) {
@ -284,8 +284,10 @@ public class TableMetaDataContext { @@ -284,8 +284,10 @@ public class TableMetaDataContext {
insertStatement.append(") VALUES(");
if (columnCount < 1) {
if (this.generatedKeyColumnsUsed) {
logger.info("Unable to locate non-key columns for table '" +
getTableName() + "' so an empty insert statement is generated");
if (logger.isInfoEnabled()) {
logger.info("Unable to locate non-key columns for table '" +
getTableName() + "' so an empty insert statement is generated");
}
}
else {
throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
@ -352,6 +354,9 @@ public class TableMetaDataContext { @@ -352,6 +354,9 @@ public class TableMetaDataContext {
}
/**
* Does this database support a simple query to retrieve generated keys
* when the JDBC 3.0 feature is not supported:
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
* @deprecated as of 4.3.15, in favor of {@link #getSimpleQueryForGetGeneratedKey}
*/
@Deprecated

8
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -87,8 +87,8 @@ public class EmbeddedDatabaseFactory { @@ -87,8 +87,8 @@ public class EmbeddedDatabaseFactory {
* generation of a pseudo-random unique ID to be used as the database name.
* <p>Setting this flag to {@code true} overrides any explicit name set
* via {@link #setDatabaseName}.
* @see #setDatabaseName
* @since 4.2
* @see #setDatabaseName
*/
public void setGenerateUniqueDatabaseName(boolean generateUniqueDatabaseName) {
this.generateUniqueDatabaseName = generateUniqueDatabaseName;
@ -183,7 +183,7 @@ public class EmbeddedDatabaseFactory { @@ -183,7 +183,7 @@ public class EmbeddedDatabaseFactory {
if (this.dataSource instanceof SimpleDriverDataSource) {
SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource;
logger.info(String.format("Starting embedded database: url='%s', username='%s'",
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
}
else {
logger.info(String.format("Starting embedded database '%s'", this.databaseName));
@ -211,7 +211,6 @@ public class EmbeddedDatabaseFactory { @@ -211,7 +211,6 @@ public class EmbeddedDatabaseFactory {
*/
protected void shutdownDatabase() {
if (this.dataSource != null) {
if (logger.isInfoEnabled()) {
if (this.dataSource instanceof SimpleDriverDataSource) {
logger.info(String.format("Shutting down embedded database: url='%s'",
@ -221,7 +220,6 @@ public class EmbeddedDatabaseFactory { @@ -221,7 +220,6 @@ public class EmbeddedDatabaseFactory {
logger.info(String.format("Shutting down embedded database '%s'", this.databaseName));
}
}
this.databaseConfigurer.shutdown(this.dataSource, this.databaseName);
this.dataSource = null;
}

6
spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -123,8 +123,8 @@ public class SQLErrorCodesFactory { @@ -123,8 +123,8 @@ public class SQLErrorCodesFactory {
// Check all beans of type SQLErrorCodes.
errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false);
if (logger.isInfoEnabled()) {
logger.info("SQLErrorCodes loaded: " + errorCodes.keySet());
if (logger.isDebugEnabled()) {
logger.debug("SQLErrorCodes loaded: " + errorCodes.keySet());
}
}
catch (BeansException ex) {

4
spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -187,7 +187,7 @@ public class TemporaryLobCreator implements LobCreator { @@ -187,7 +187,7 @@ public class TemporaryLobCreator implements LobCreator {
}
}
catch (SQLException ex) {
logger.error("Could not free LOB", ex);
logger.error("Could not free LOBs", ex);
}
}

4
spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
@ -25,7 +25,7 @@ import org.springframework.messaging.MessageHeaders; @@ -25,7 +25,7 @@ import org.springframework.messaging.MessageHeaders;
import org.springframework.util.StringUtils;
/**
* A base {@link HeaderMapper} implementation
* A base {@link HeaderMapper} implementation.
*
* @author Stephane Nicoll
* @since 4.1

19
spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -208,7 +208,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe @@ -208,7 +208,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
if (this.targetClass != null) {
if (StringUtils.hasLength(this.bindingName)) {
if (logger.isInfoEnabled()) {
logger.info("Configured for target class [" + this.targetClass + "] using binding [" + this.bindingName + "]");
logger.info("Configured for target class [" + this.targetClass +
"] using binding [" + this.bindingName + "]");
}
this.bindingFactory = BindingDirectory.getFactory(this.bindingName, this.targetClass);
}
@ -220,11 +221,12 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe @@ -220,11 +221,12 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
}
}
else if (this.targetPackage != null) {
if (!StringUtils.hasLength(bindingName)) {
bindingName = DEFAULT_BINDING_NAME;
if (!StringUtils.hasLength(this.bindingName)) {
this.bindingName = DEFAULT_BINDING_NAME;
}
if (logger.isInfoEnabled()) {
logger.info("Configured for target package [" + this.targetPackage + "] using binding [" + this.bindingName + "]");
logger.info("Configured for target package [" + this.targetPackage +
"] using binding [" + this.bindingName + "]");
}
this.bindingFactory = BindingDirectory.getFactory(this.bindingName, this.targetPackage);
}
@ -279,9 +281,10 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe @@ -279,9 +281,10 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
}
private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException {
if (StringUtils.hasLength(docTypeRootElementName)) {
if (StringUtils.hasLength(this.docTypeRootElementName)) {
IXMLWriter xmlWriter = marshallingContext.getXmlWriter();
xmlWriter.writeDocType(docTypeRootElementName, docTypeSystemId, docTypePublicId, docTypeInternalSubset);
xmlWriter.writeDocType(this.docTypeRootElementName, this.docTypeSystemId,
this.docTypePublicId, this.docTypeInternalSubset);
}
marshallingContext.marshalDocument(graph);
}
@ -380,7 +383,7 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe @@ -380,7 +383,7 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
try {
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
return unmarshallingContext.unmarshalDocument(inputStream, encoding);
return unmarshallingContext.unmarshalDocument(inputStream, this.encoding);
}
catch (JiBXException ex) {
throw convertJibxException(ex, false);

6
spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -74,7 +74,9 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho @@ -74,7 +74,9 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(type);
if (resolver.hasExceptionMappings()) {
registerExceptionHandlerAdvice(bean, resolver);
logger.info("Detected @MessageExceptionHandler methods in " + bean);
if (logger.isInfoEnabled()) {
logger.info("Detected @MessageExceptionHandler methods in " + bean);
}
}
}
}

Loading…
Cancel
Save