Browse Source

Polishing

pull/1916/head
Juergen Hoeller 8 years ago
parent
commit
c3f6403f61
  1. 2
      spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java
  2. 8
      spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java
  3. 18
      spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java
  4. 4
      spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java
  5. 10
      spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java
  6. 9
      spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java
  7. 6
      spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationBasedExporter.java
  8. 4
      spring-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java
  9. 12
      spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java
  10. 6
      spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
  11. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java
  12. 11
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
  13. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java
  14. 6
      spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java
  15. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java
  16. 4
      spring-messaging/src/main/java/org/springframework/messaging/support/AbstractHeaderMapper.java
  17. 19
      spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java
  18. 6
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java
  19. 6
      spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java

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

@ -651,7 +651,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
} }
public String getBeanName() { public String getBeanName() {
return beanName; return this.beanName;
} }
@Override @Override

8
spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.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"); * 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.
@ -74,8 +74,8 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
* @param target the bean instance to destroy * @param target the bean instance to destroy
*/ */
protected void destroyPrototypeInstance(Object target) { protected void destroyPrototypeInstance(Object target) {
if (this.logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
this.logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'"); logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
} }
if (getBeanFactory() instanceof ConfigurableBeanFactory) { if (getBeanFactory() instanceof ConfigurableBeanFactory) {
((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target); ((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target);
@ -85,7 +85,7 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
((DisposableBean) target).destroy(); ((DisposableBean) target).destroy();
} }
catch (Throwable ex) { catch (Throwable ex) {
logger.error("Couldn't invoke destroy method of bean with name '" + getTargetBeanName() + "'", ex); logger.error("Destroy method on bean with name '" + getTargetBeanName() + "' threw an exception", ex);
} }
} }
} }

18
spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.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"); * 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.
@ -248,12 +248,12 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
try { try {
if (System.getSecurityManager() != null) { if (System.getSecurityManager() != null) {
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> { AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
((DisposableBean) bean).destroy(); ((DisposableBean) this.bean).destroy();
return null; return null;
}, acc); }, this.acc);
} }
else { else {
((DisposableBean) bean).destroy(); ((DisposableBean) this.bean).destroy();
} }
} }
catch (Throwable ex) { catch (Throwable ex) {
@ -326,7 +326,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
}); });
try { try {
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
destroyMethod.invoke(bean, args), acc); destroyMethod.invoke(this.bean, args), this.acc);
} }
catch (PrivilegedActionException pax) { catch (PrivilegedActionException pax) {
throw (InvocationTargetException) pax.getException(); throw (InvocationTargetException) pax.getException();
@ -334,12 +334,12 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
} }
else { else {
ReflectionUtils.makeAccessible(destroyMethod); ReflectionUtils.makeAccessible(destroyMethod);
destroyMethod.invoke(bean, args); destroyMethod.invoke(this.bean, args);
} }
} }
catch (InvocationTargetException ex) { catch (InvocationTargetException ex) {
String msg = "Invocation of destroy method '" + this.destroyMethodName + String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
"' failed on bean with name '" + this.beanName + "'"; this.beanName + "' threw an exception";
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.warn(msg, ex.getTargetException()); logger.warn(msg, ex.getTargetException());
} }
@ -348,7 +348,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
} }
} }
catch (Throwable ex) { catch (Throwable ex) {
logger.error("Couldn't invoke destroy method '" + this.destroyMethodName + logger.error("Failed to invoke destroy method '" + this.destroyMethodName +
"' on bean with name '" + this.beanName + "'", ex); "' on bean with name '" + this.beanName + "'", ex);
} }
} }

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

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

@ -151,7 +151,9 @@ public class MBeanRegistrationSupport {
registeredBean = this.server.registerMBean(mbean, objectName); registeredBean = this.server.registerMBean(mbean, objectName);
} }
catch (InstanceNotFoundException ex2) { 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; throw ex;
} }
} }
@ -181,9 +183,9 @@ public class MBeanRegistrationSupport {
} }
if (!snapshot.isEmpty()) { if (!snapshot.isEmpty()) {
logger.info("Unregistering JMX-exposed beans"); logger.info("Unregistering JMX-exposed beans");
} for (ObjectName objectName : snapshot) {
for (ObjectName objectName : snapshot) { doUnregister(objectName);
doUnregister(objectName); }
} }
} }

9
spring-context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.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"); * 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.
@ -436,8 +436,8 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
} }
catch (NotBoundException ex) { catch (NotBoundException ex) {
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn("RMI service '" + this.serviceName + "' is not bound to registry" logger.warn("RMI service '" + this.serviceName + "' is not bound to registry" +
+ (this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex); (this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex);
} }
} }
finally { finally {
@ -454,8 +454,9 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
} }
catch (NoSuchObjectException ex) { catch (NoSuchObjectException ex) {
if (logger.isWarnEnabled()) { 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 @@
/* /*
* 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"); * 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.
@ -79,13 +79,13 @@ public abstract class RemoteInvocationBasedExporter extends RemoteExporter {
} }
catch (NoSuchMethodException ex) { catch (NoSuchMethodException ex) {
if (logger.isDebugEnabled()) { 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; throw ex;
} }
catch (IllegalAccessException ex) { catch (IllegalAccessException ex) {
if (logger.isDebugEnabled()) { 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; throw ex;
} }

4
spring-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.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"); * 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.
@ -157,7 +157,7 @@ public class ScheduledExecutorFactoryBean extends ExecutorConfigurationSupport
((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true); ((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true);
} }
else { else {
logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); logger.info("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
} }
} }

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

@ -99,7 +99,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(removeOnCancelPolicy); ((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(removeOnCancelPolicy);
} }
else if (removeOnCancelPolicy && this.scheduledExecutor != null) { else if (removeOnCancelPolicy && this.scheduledExecutor != null) {
logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); logger.info("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
} }
} }
@ -122,7 +122,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(true); ((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(true);
} }
else { else {
logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); logger.info("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
} }
} }
@ -284,8 +284,8 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
private void executeAndTrack(ExecutorService executor, ListenableFutureTask<?> listenableFuture) { private void executeAndTrack(ExecutorService executor, ListenableFutureTask<?> listenableFuture) {
Future<?> scheduledFuture = executor.submit(errorHandlingTask(listenableFuture, false)); Future<?> scheduledFuture = executor.submit(errorHandlingTask(listenableFuture, false));
this.listenableFutureMap.put(scheduledFuture, listenableFuture); this.listenableFutureMap.put(scheduledFuture, listenableFuture);
listenableFuture.addCallback(result -> listenableFutureMap.remove(scheduledFuture), listenableFuture.addCallback(result -> this.listenableFutureMap.remove(scheduledFuture),
ex -> listenableFutureMap.remove(scheduledFuture)); ex -> this.listenableFutureMap.remove(scheduledFuture));
} }
@Override @Override
@ -403,8 +403,8 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
try { try {
return this.delegate.call(); return this.delegate.call();
} }
catch (Throwable t) { catch (Throwable ex) {
this.errorHandler.handleError(t); this.errorHandler.handleError(ex);
return null; return null;
} }
} }

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

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

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

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

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

@ -264,7 +264,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 * @return the insert string to be used
*/ */
public String createInsertString(String... generatedKeyNames) { public String createInsertString(String... generatedKeyNames) {
@ -293,8 +293,10 @@ public class TableMetaDataContext {
insertStatement.append(") VALUES("); insertStatement.append(") VALUES(");
if (columnCount < 1) { if (columnCount < 1) {
if (this.generatedKeyColumnsUsed) { if (this.generatedKeyColumnsUsed) {
logger.info("Unable to locate non-key columns for table '" + if (logger.isInfoEnabled()) {
getTableName() + "' so an empty insert statement is generated"); logger.info("Unable to locate non-key columns for table '" +
getTableName() + "' so an empty insert statement is generated");
}
} }
else { else {
throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" + throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
@ -360,6 +362,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 as of 4.3.15, in favor of {@link #getSimpleQueryForGetGeneratedKey}
*/ */
@Deprecated @Deprecated

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

@ -91,8 +91,8 @@ public class EmbeddedDatabaseFactory {
* generation of a pseudo-random unique ID to be used as the database name. * 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 * <p>Setting this flag to {@code true} overrides any explicit name set
* via {@link #setDatabaseName}. * via {@link #setDatabaseName}.
* @see #setDatabaseName
* @since 4.2 * @since 4.2
* @see #setDatabaseName
*/ */
public void setGenerateUniqueDatabaseName(boolean generateUniqueDatabaseName) { public void setGenerateUniqueDatabaseName(boolean generateUniqueDatabaseName) {
this.generateUniqueDatabaseName = generateUniqueDatabaseName; this.generateUniqueDatabaseName = generateUniqueDatabaseName;
@ -187,7 +187,7 @@ public class EmbeddedDatabaseFactory {
if (this.dataSource instanceof SimpleDriverDataSource) { if (this.dataSource instanceof SimpleDriverDataSource) {
SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource; SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource;
logger.info(String.format("Starting embedded database: url='%s', username='%s'", logger.info(String.format("Starting embedded database: url='%s', username='%s'",
simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername())); simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
} }
else { else {
logger.info(String.format("Starting embedded database '%s'", this.databaseName)); logger.info(String.format("Starting embedded database '%s'", this.databaseName));

6
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"); * 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.
@ -124,8 +124,8 @@ public class SQLErrorCodesFactory {
// Check all beans of type SQLErrorCodes. // Check all beans of type SQLErrorCodes.
errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false); errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false);
if (logger.isInfoEnabled()) { if (logger.isDebugEnabled()) {
logger.info("SQLErrorCodes loaded: " + errorCodes.keySet()); logger.debug("SQLErrorCodes loaded: " + errorCodes.keySet());
} }
} }
catch (BeansException ex) { catch (BeansException ex) {

4
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"); * 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.
@ -188,7 +188,7 @@ public class TemporaryLobCreator implements LobCreator {
} }
} }
catch (SQLException ex) { 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 @@
/* /*
* 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"); * 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.
@ -26,7 +26,7 @@ import org.springframework.messaging.MessageHeaders;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* A base {@link HeaderMapper} implementation * A base {@link HeaderMapper} implementation.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 4.1 * @since 4.1

19
spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.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"); * 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.
@ -218,7 +218,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
if (this.targetClass != null) { if (this.targetClass != null) {
if (StringUtils.hasLength(this.bindingName)) { if (StringUtils.hasLength(this.bindingName)) {
if (logger.isInfoEnabled()) { 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); this.bindingFactory = BindingDirectory.getFactory(this.bindingName, this.targetClass);
} }
@ -230,11 +231,12 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
} }
} }
else if (this.targetPackage != null) { else if (this.targetPackage != null) {
if (!StringUtils.hasLength(bindingName)) { if (!StringUtils.hasLength(this.bindingName)) {
bindingName = DEFAULT_BINDING_NAME; this.bindingName = DEFAULT_BINDING_NAME;
} }
if (logger.isInfoEnabled()) { 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); this.bindingFactory = BindingDirectory.getFactory(this.bindingName, this.targetPackage);
} }
@ -290,9 +292,10 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
} }
private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException { private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException {
if (StringUtils.hasLength(docTypeRootElementName)) { if (StringUtils.hasLength(this.docTypeRootElementName)) {
IXMLWriter xmlWriter = marshallingContext.getXmlWriter(); IXMLWriter xmlWriter = marshallingContext.getXmlWriter();
xmlWriter.writeDocType(docTypeRootElementName, docTypeSystemId, docTypePublicId, docTypeInternalSubset); xmlWriter.writeDocType(this.docTypeRootElementName, this.docTypeSystemId,
this.docTypePublicId, this.docTypeInternalSubset);
} }
marshallingContext.marshalDocument(graph); marshallingContext.marshalDocument(graph);
} }
@ -391,7 +394,7 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException { protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
try { try {
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext(); IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
return unmarshallingContext.unmarshalDocument(inputStream, encoding); return unmarshallingContext.unmarshalDocument(inputStream, this.encoding);
} }
catch (JiBXException ex) { catch (JiBXException ex) {
throw convertJibxException(ex, false); throw convertJibxException(ex, false);

6
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"); * 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.
@ -76,7 +76,9 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(type); AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(type);
if (resolver.hasExceptionMappings()) { if (resolver.hasExceptionMappings()) {
registerExceptionHandlerAdvice(bean, resolver); registerExceptionHandlerAdvice(bean, resolver);
logger.info("Detected @MessageExceptionHandler methods in " + bean); if (logger.isInfoEnabled()) {
logger.info("Detected @MessageExceptionHandler methods in " + bean);
}
} }
} }
} }

6
spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java

@ -145,9 +145,9 @@ public class ServerEndpointExporter extends WebApplicationObjectSupport
ServerContainer serverContainer = getServerContainer(); ServerContainer serverContainer = getServerContainer();
Assert.state(serverContainer != null, Assert.state(serverContainer != null,
"No ServerContainer set. Most likely the server's own WebSocket ServletContainerInitializer " + "No ServerContainer set. Most likely the server's own WebSocket ServletContainerInitializer " +
"has not run yet. Was the Spring ApplicationContext refreshed through a " + "has not run yet. Was the Spring ApplicationContext refreshed through a " +
"org.springframework.web.context.ContextLoaderListener, " + "org.springframework.web.context.ContextLoaderListener, " +
"i.e. after the ServletContext has been fully initialized?"); "i.e. after the ServletContext has been fully initialized?");
try { try {
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
logger.info("Registering @ServerEndpoint class: " + endpointClass); logger.info("Registering @ServerEndpoint class: " + endpointClass);

Loading…
Cancel
Save