Skip to content

Commit c3f6403

Browse files
committed
Polishing
1 parent 5007d01 commit c3f6403

File tree

19 files changed

+80
-63
lines changed

19 files changed

+80
-63
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public PrototypePlaceholderAdvisor(String beanName) {
651651
}
652652

653653
public String getBeanName() {
654-
return beanName;
654+
return this.beanName;
655655
}
656656

657657
@Override

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

Lines changed: 4 additions & 4 deletions
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.
@@ -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);
@@ -85,7 +85,7 @@ else if (target instanceof DisposableBean) {
8585
((DisposableBean) target).destroy();
8686
}
8787
catch (Throwable ex) {
88-
logger.error("Couldn't invoke destroy method of bean with name '" + getTargetBeanName() + "'", ex);
88+
logger.error("Destroy method on bean with name '" + getTargetBeanName() + "' threw an exception", ex);
8989
}
9090
}
9191
}

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 9 additions & 9 deletions
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.
@@ -248,12 +248,12 @@ public void destroy() {
248248
try {
249249
if (System.getSecurityManager() != null) {
250250
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
251-
((DisposableBean) bean).destroy();
251+
((DisposableBean) this.bean).destroy();
252252
return null;
253-
}, acc);
253+
}, this.acc);
254254
}
255255
else {
256-
((DisposableBean) bean).destroy();
256+
((DisposableBean) this.bean).destroy();
257257
}
258258
}
259259
catch (Throwable ex) {
@@ -326,20 +326,20 @@ private void invokeCustomDestroyMethod(final Method destroyMethod) {
326326
});
327327
try {
328328
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
329-
destroyMethod.invoke(bean, args), acc);
329+
destroyMethod.invoke(this.bean, args), this.acc);
330330
}
331331
catch (PrivilegedActionException pax) {
332332
throw (InvocationTargetException) pax.getException();
333333
}
334334
}
335335
else {
336336
ReflectionUtils.makeAccessible(destroyMethod);
337-
destroyMethod.invoke(bean, args);
337+
destroyMethod.invoke(this.bean, args);
338338
}
339339
}
340340
catch (InvocationTargetException ex) {
341-
String msg = "Invocation of destroy method '" + this.destroyMethodName +
342-
"' failed on bean with name '" + this.beanName + "'";
341+
String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
342+
this.beanName + "' threw an exception";
343343
if (logger.isDebugEnabled()) {
344344
logger.warn(msg, ex.getTargetException());
345345
}
@@ -348,7 +348,7 @@ private void invokeCustomDestroyMethod(final Method destroyMethod) {
348348
}
349349
}
350350
catch (Throwable ex) {
351-
logger.error("Couldn't invoke destroy method '" + this.destroyMethodName +
351+
logger.error("Failed to invoke destroy method '" + this.destroyMethodName +
352352
"' on bean with name '" + this.beanName + "'", ex);
353353
}
354354
}

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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ else if (this.registrationPolicy == RegistrationPolicy.REPLACE_EXISTING) {
151151
registeredBean = this.server.registerMBean(mbean, objectName);
152152
}
153153
catch (InstanceNotFoundException ex2) {
154-
logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
154+
if (logger.isErrorEnabled()) {
155+
logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
156+
}
155157
throw ex;
156158
}
157159
}
@@ -181,9 +183,9 @@ protected void unregisterBeans() {
181183
}
182184
if (!snapshot.isEmpty()) {
183185
logger.info("Unregistering JMX-exposed beans");
184-
}
185-
for (ObjectName objectName : snapshot) {
186-
doUnregister(objectName);
186+
for (ObjectName objectName : snapshot) {
187+
doUnregister(objectName);
188+
}
187189
}
188190
}
189191

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-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.
@@ -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-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java

Lines changed: 2 additions & 2 deletions
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.
@@ -157,7 +157,7 @@ protected ExecutorService initializeExecutor(
157157
((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true);
158158
}
159159
else {
160-
logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor");
160+
logger.info("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
161161
}
162162
}
163163

spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void setRemoveOnCancelPolicy(boolean removeOnCancelPolicy) {
9999
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(removeOnCancelPolicy);
100100
}
101101
else if (removeOnCancelPolicy && this.scheduledExecutor != null) {
102-
logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor");
102+
logger.info("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
103103
}
104104
}
105105

@@ -122,7 +122,7 @@ protected ExecutorService initializeExecutor(
122122
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(true);
123123
}
124124
else {
125-
logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor");
125+
logger.info("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
126126
}
127127
}
128128

@@ -284,8 +284,8 @@ public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
284284
private void executeAndTrack(ExecutorService executor, ListenableFutureTask<?> listenableFuture) {
285285
Future<?> scheduledFuture = executor.submit(errorHandlingTask(listenableFuture, false));
286286
this.listenableFutureMap.put(scheduledFuture, listenableFuture);
287-
listenableFuture.addCallback(result -> listenableFutureMap.remove(scheduledFuture),
288-
ex -> listenableFutureMap.remove(scheduledFuture));
287+
listenableFuture.addCallback(result -> this.listenableFutureMap.remove(scheduledFuture),
288+
ex -> this.listenableFutureMap.remove(scheduledFuture));
289289
}
290290

291291
@Override
@@ -403,8 +403,8 @@ public V call() throws Exception {
403403
try {
404404
return this.delegate.call();
405405
}
406-
catch (Throwable t) {
407-
this.errorHandler.handleError(t);
406+
catch (Throwable ex) {
407+
this.errorHandler.handleError(ex);
408408
return null;
409409
}
410410
}

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;
@@ -250,6 +251,9 @@ protected Set<String> doGetActiveProfiles() {
250251
@Override
251252
public void setActiveProfiles(String... profiles) {
252253
Assert.notNull(profiles, "Profile array must not be null");
254+
if (logger.isDebugEnabled()) {
255+
logger.debug("Activating profiles " + Arrays.asList(profiles));
256+
}
253257
synchronized (this.activeProfiles) {
254258
this.activeProfiles.clear();
255259
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
@@ -520,7 +520,7 @@ public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameter
520520
matchedParameters.put(parameterName,
521521
SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
522522
}
523-
else {
523+
else if (logger.isWarnEnabled()) {
524524
logger.warn("Unable to locate the corresponding parameter value for '" +
525525
parameterName + "' within the parameter values provided: " +
526526
caseInsensitiveParameterNames.values());
@@ -587,7 +587,7 @@ public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameter
587587
for (String parameterName : callParameterNames.keySet()) {
588588
String parameterNameToMatch = provider.parameterNameToUse(parameterName);
589589
String callParameterName = callParameterNames.get(lowerCase(parameterNameToMatch));
590-
if (!matchedParameters.containsKey(callParameterName)) {
590+
if (!matchedParameters.containsKey(callParameterName) && logger.isWarnEnabled()) {
591591
logger.warn("Unable to locate the corresponding parameter value for '" + parameterName +
592592
"' within the parameter values provided: " + inParameters.keySet());
593593
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public List<Object> matchInParameterValuesWithInsertColumns(Map<String, ?> inPar
264264

265265

266266
/**
267-
* Build the insert string based on configuration and meta-data information
267+
* Build the insert string based on configuration and meta-data information.
268268
* @return the insert string to be used
269269
*/
270270
public String createInsertString(String... generatedKeyNames) {
@@ -293,8 +293,10 @@ public String createInsertString(String... generatedKeyNames) {
293293
insertStatement.append(") VALUES(");
294294
if (columnCount < 1) {
295295
if (this.generatedKeyColumnsUsed) {
296-
logger.info("Unable to locate non-key columns for table '" +
297-
getTableName() + "' so an empty insert statement is generated");
296+
if (logger.isInfoEnabled()) {
297+
logger.info("Unable to locate non-key columns for table '" +
298+
getTableName() + "' so an empty insert statement is generated");
299+
}
298300
}
299301
else {
300302
throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
@@ -360,6 +362,9 @@ public boolean isGetGeneratedKeysSimulated() {
360362
}
361363

362364
/**
365+
* Does this database support a simple query to retrieve generated keys
366+
* when the JDBC 3.0 feature is not supported:
367+
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
363368
* @deprecated as of 4.3.15, in favor of {@link #getSimpleQueryForGetGeneratedKey}
364369
*/
365370
@Deprecated

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public class EmbeddedDatabaseFactory {
9191
* generation of a pseudo-random unique ID to be used as the database name.
9292
* <p>Setting this flag to {@code true} overrides any explicit name set
9393
* via {@link #setDatabaseName}.
94-
* @see #setDatabaseName
9594
* @since 4.2
95+
* @see #setDatabaseName
9696
*/
9797
public void setGenerateUniqueDatabaseName(boolean generateUniqueDatabaseName) {
9898
this.generateUniqueDatabaseName = generateUniqueDatabaseName;
@@ -187,7 +187,7 @@ protected void initDatabase() {
187187
if (this.dataSource instanceof SimpleDriverDataSource) {
188188
SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource;
189189
logger.info(String.format("Starting embedded database: url='%s', username='%s'",
190-
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
190+
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
191191
}
192192
else {
193193
logger.info(String.format("Starting embedded database '%s'", this.databaseName));

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

Lines changed: 3 additions & 3 deletions
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.
@@ -124,8 +124,8 @@ protected SQLErrorCodesFactory() {
124124

125125
// Check all beans of type SQLErrorCodes.
126126
errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false);
127-
if (logger.isInfoEnabled()) {
128-
logger.info("SQLErrorCodes loaded: " + errorCodes.keySet());
127+
if (logger.isDebugEnabled()) {
128+
logger.debug("SQLErrorCodes loaded: " + errorCodes.keySet());
129129
}
130130
}
131131
catch (BeansException ex) {

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

Lines changed: 2 additions & 2 deletions
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.
@@ -188,7 +188,7 @@ public void close() {
188188
}
189189
}
190190
catch (SQLException ex) {
191-
logger.error("Could not free LOB", ex);
191+
logger.error("Could not free LOBs", ex);
192192
}
193193
}
194194

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

Lines changed: 2 additions & 2 deletions
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.
@@ -26,7 +26,7 @@
2626
import org.springframework.util.StringUtils;
2727

2828
/**
29-
* A base {@link HeaderMapper} implementation
29+
* A base {@link HeaderMapper} implementation.
3030
*
3131
* @author Stephane Nicoll
3232
* @since 4.1

0 commit comments

Comments
 (0)