diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java index d24c5259094..a56b5dcd2d2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java @@ -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 } public String getBeanName() { - return beanName; + return this.beanName; } @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java index 415d0e57e12..450f431abeb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java @@ -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 * @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); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java b/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java index c02ceb33192..399fc74510b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java @@ -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 { } } } - 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 " + diff --git a/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java b/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java index 97ee1c6d15f..b80d30bd3d3 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java @@ -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 { 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 { } if (!snapshot.isEmpty()) { logger.info("Unregistering JMX-exposed beans"); - } - for (ObjectName objectName : snapshot) { - doUnregister(objectName); + for (ObjectName objectName : snapshot) { + doUnregister(objectName); + } } } diff --git a/spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java b/spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java index 6f05da086d6..8541a05477a 100644 --- a/spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java +++ b/spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java @@ -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 } 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 } 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); } } } + } diff --git a/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java b/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java index edd3e72eadf..cd07dc9ad6d 100644 --- a/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java +++ b/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java @@ -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 { } 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; } diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index 4d00810b6b1..1ffb98bdb1a 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -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 @@ 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 { @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) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java index 64ddd6ca482..298c58c0e67 100755 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java @@ -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 { 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()); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java index 5d33b7fad77..f74095d446f 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java @@ -182,7 +182,7 @@ public class TableMetaDataContext { if (generatedKeyNames.length > 0) { this.generatedKeyColumnsUsed = true; } - if (declaredColumns.size() > 0) { + if (!declaredColumns.isEmpty()) { return new ArrayList(declaredColumns); } Set keys = new LinkedHashSet(generatedKeyNames.length); @@ -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 { 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 { } /** + * 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 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java index baf30e4052c..962d81b87cc 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java @@ -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 { * generation of a pseudo-random unique ID to be used as the database name. *

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 { 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 { */ 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 { logger.info(String.format("Shutting down embedded database '%s'", this.databaseName)); } } - this.databaseConfigurer.shutdown(this.dataSource, this.databaseName); this.dataSource = null; } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java index 2301700f9cb..72737c4c894 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java @@ -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 { // 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) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java index 43938efffc0..028e2ad5df8 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java @@ -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 { } } catch (SQLException ex) { - logger.error("Could not free LOB", ex); + logger.error("Could not free LOBs", ex); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java index 5d9b4d9415a..f21d2e9e123 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java @@ -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; import org.springframework.util.StringUtils; /** - * A base {@link HeaderMapper} implementation + * A base {@link HeaderMapper} implementation. * * @author Stephane Nicoll * @since 4.1 diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java index c481fd1b219..97290ff563b 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java @@ -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 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 } } 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 } 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 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); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java index 959e3e9e915..bd0c2c976b6 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java @@ -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 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); + } } } }