Skip to content

Commit 484addb

Browse files
committed
Polishing
1 parent 65e4232 commit 484addb

File tree

15 files changed

+63
-48
lines changed

15 files changed

+63
-48
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -640,7 +640,7 @@ public PrototypePlaceholderAdvisor(String beanName) {
640640
}
641641

642642
public String getBeanName() {
643-
return beanName;
643+
return this.beanName;
644644
}
645645

646646
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -74,8 +74,8 @@ protected Object newPrototypeInstance() throws BeansException {
7474
* @param target the bean instance to destroy
7575
*/
7676
protected void destroyPrototypeInstance(Object target) {
77-
if (this.logger.isDebugEnabled()) {
78-
this.logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
77+
if (logger.isDebugEnabled()) {
78+
logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
7979
}
8080
if (getBeanFactory() instanceof ConfigurableBeanFactory) {
8181
((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -77,7 +77,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
7777
}
7878
}
7979
}
80-
if (!candidateFound) {
80+
if (!candidateFound && logger.isWarnEnabled()) {
8181
String name = getClass().getSimpleName();
8282
logger.warn(String.format("%s was imported but no annotations were found " +
8383
"having both 'mode' and 'proxyTargetClass' attributes of type " +

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -209,7 +209,9 @@ else if (this.registrationPolicy == RegistrationPolicy.REPLACE_EXISTING) {
209209
registeredBean = this.server.registerMBean(mbean, objectName);
210210
}
211211
catch (InstanceNotFoundException ex2) {
212-
logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
212+
if (logger.isErrorEnabled()) {
213+
logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
214+
}
213215
throw ex;
214216
}
215217
}
@@ -239,9 +241,9 @@ protected void unregisterBeans() {
239241
}
240242
if (!snapshot.isEmpty()) {
241243
logger.info("Unregistering JMX-exposed beans");
242-
}
243-
for (ObjectName objectName : snapshot) {
244-
doUnregister(objectName);
244+
for (ObjectName objectName : snapshot) {
245+
doUnregister(objectName);
246+
}
245247
}
246248
}
247249

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

Lines changed: 5 additions & 4 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-2018 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.
@@ -436,8 +436,8 @@ public void destroy() throws RemoteException {
436436
}
437437
catch (NotBoundException ex) {
438438
if (logger.isWarnEnabled()) {
439-
logger.warn("RMI service '" + this.serviceName + "' is not bound to registry"
440-
+ (this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex);
439+
logger.warn("RMI service '" + this.serviceName + "' is not bound to registry" +
440+
(this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex);
441441
}
442442
}
443443
finally {
@@ -454,8 +454,9 @@ private void unexportObjectSilently() {
454454
}
455455
catch (NoSuchObjectException ex) {
456456
if (logger.isWarnEnabled()) {
457-
logger.warn("RMI object for service '" + this.serviceName + "' isn't exported anymore", ex);
457+
logger.warn("RMI object for service '" + this.serviceName + "' is not exported anymore", ex);
458458
}
459459
}
460460
}
461+
461462
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -79,13 +79,13 @@ protected Object invoke(RemoteInvocation invocation, Object targetObject)
7979
}
8080
catch (NoSuchMethodException ex) {
8181
if (logger.isDebugEnabled()) {
82-
logger.warn("Could not find target method for " + invocation, ex);
82+
logger.debug("Could not find target method for " + invocation, ex);
8383
}
8484
throw ex;
8585
}
8686
catch (IllegalAccessException ex) {
8787
if (logger.isDebugEnabled()) {
88-
logger.warn("Could not access target method for " + invocation, ex);
88+
logger.debug("Could not access target method for " + invocation, ex);
8989
}
9090
throw ex;
9191
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -17,6 +17,7 @@
1717
package org.springframework.core.env;
1818

1919
import java.security.AccessControlException;
20+
import java.util.Arrays;
2021
import java.util.Collections;
2122
import java.util.LinkedHashSet;
2223
import java.util.Map;
@@ -249,6 +250,9 @@ protected Set<String> doGetActiveProfiles() {
249250
@Override
250251
public void setActiveProfiles(String... profiles) {
251252
Assert.notNull(profiles, "Profile array must not be null");
253+
if (logger.isDebugEnabled()) {
254+
logger.debug("Activating profiles " + Arrays.asList(profiles));
255+
}
252256
synchronized (this.activeProfiles) {
253257
this.activeProfiles.clear();
254258
for (String profile : profiles) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameter
496496
matchedParameters.put(parameterName,
497497
SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
498498
}
499-
else {
499+
else if (logger.isWarnEnabled()) {
500500
logger.warn("Unable to locate the corresponding parameter value for '" +
501501
parameterName + "' within the parameter values provided: " +
502502
caseInsensitiveParameterNames.values());
@@ -562,7 +562,7 @@ public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameter
562562
for (String parameterName : callParameterNames.keySet()) {
563563
String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
564564
String callParameterName = callParameterNames.get(parameterNameToMatch.toLowerCase());
565-
if (!matchedParameters.containsKey(callParameterName)) {
565+
if (!matchedParameters.containsKey(callParameterName) && logger.isWarnEnabled()) {
566566
logger.warn("Unable to locate the corresponding parameter value for '" + parameterName +
567567
"' within the parameter values provided: " + inParameters.keySet());
568568
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected List<String> reconcileColumnsToUse(List<String> declaredColumns, Strin
182182
if (generatedKeyNames.length > 0) {
183183
this.generatedKeyColumnsUsed = true;
184184
}
185-
if (declaredColumns.size() > 0) {
185+
if (!declaredColumns.isEmpty()) {
186186
return new ArrayList<String>(declaredColumns);
187187
}
188188
Set<String> keys = new LinkedHashSet<String>(generatedKeyNames.length);
@@ -255,7 +255,7 @@ public List<Object> matchInParameterValuesWithInsertColumns(Map<String, ?> inPar
255255

256256

257257
/**
258-
* Build the insert string based on configuration and meta-data information
258+
* Build the insert string based on configuration and meta-data information.
259259
* @return the insert string to be used
260260
*/
261261
public String createInsertString(String... generatedKeyNames) {
@@ -284,8 +284,10 @@ public String createInsertString(String... generatedKeyNames) {
284284
insertStatement.append(") VALUES(");
285285
if (columnCount < 1) {
286286
if (this.generatedKeyColumnsUsed) {
287-
logger.info("Unable to locate non-key columns for table '" +
288-
getTableName() + "' so an empty insert statement is generated");
287+
if (logger.isInfoEnabled()) {
288+
logger.info("Unable to locate non-key columns for table '" +
289+
getTableName() + "' so an empty insert statement is generated");
290+
}
289291
}
290292
else {
291293
throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
@@ -352,6 +354,9 @@ public boolean isGetGeneratedKeysSimulated() {
352354
}
353355

354356
/**
357+
* Does this database support a simple query to retrieve generated keys
358+
* when the JDBC 3.0 feature is not supported:
359+
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
355360
* @deprecated as of 4.3.15, in favor of {@link #getSimpleQueryForGetGeneratedKey}
356361
*/
357362
@Deprecated

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -87,8 +87,8 @@ public class EmbeddedDatabaseFactory {
8787
* generation of a pseudo-random unique ID to be used as the database name.
8888
* <p>Setting this flag to {@code true} overrides any explicit name set
8989
* via {@link #setDatabaseName}.
90-
* @see #setDatabaseName
9190
* @since 4.2
91+
* @see #setDatabaseName
9292
*/
9393
public void setGenerateUniqueDatabaseName(boolean generateUniqueDatabaseName) {
9494
this.generateUniqueDatabaseName = generateUniqueDatabaseName;
@@ -183,7 +183,7 @@ protected void initDatabase() {
183183
if (this.dataSource instanceof SimpleDriverDataSource) {
184184
SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource;
185185
logger.info(String.format("Starting embedded database: url='%s', username='%s'",
186-
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
186+
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
187187
}
188188
else {
189189
logger.info(String.format("Starting embedded database '%s'", this.databaseName));
@@ -211,7 +211,6 @@ protected void initDatabase() {
211211
*/
212212
protected void shutdownDatabase() {
213213
if (this.dataSource != null) {
214-
215214
if (logger.isInfoEnabled()) {
216215
if (this.dataSource instanceof SimpleDriverDataSource) {
217216
logger.info(String.format("Shutting down embedded database: url='%s'",
@@ -221,7 +220,6 @@ protected void shutdownDatabase() {
221220
logger.info(String.format("Shutting down embedded database '%s'", this.databaseName));
222221
}
223222
}
224-
225223
this.databaseConfigurer.shutdown(this.dataSource, this.databaseName);
226224
this.dataSource = null;
227225
}

0 commit comments

Comments
 (0)