Upgrade to SF 5.1; Remove Deprecated Code

Polishing - PR Comments

Remove direct log4j usage in tests

- hazelcast depends on it; retain the dependency just in jmx

Fix hazelcast logger type
This commit is contained in:
Gary Russell
2018-04-10 14:30:46 -04:00
committed by Artem Bilan
parent 27318c7ee5
commit b940e3872b
16 changed files with 33 additions and 314 deletions

View File

@@ -23,7 +23,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -39,8 +38,6 @@ import org.springframework.core.OrderComparator;
import org.springframework.integration.channel.ChannelInterceptorAware;
import org.springframework.integration.channel.interceptor.GlobalChannelInterceptorWrapper;
import org.springframework.integration.channel.interceptor.VetoCapableInterceptor;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.IntegrationProperties;
import org.springframework.integration.support.utils.PatternMatchUtils;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.util.Assert;
@@ -105,12 +102,7 @@ public final class GlobalChannelInterceptorProcessor
}
}
// TODO Remove this logic in 5.1
Properties integrationProperties = IntegrationContextUtils.getIntegrationProperties(this.beanFactory);
this.singletonsInstantiated =
Boolean.parseBoolean(integrationProperties.getProperty(
IntegrationProperties.POST_PROCESS_DYNAMIC_BEANS));
this.singletonsInstantiated = true;
}
@Override

View File

@@ -77,13 +77,6 @@ public final class IntegrationProperties {
*/
public static final String ENDPOINTS_NO_AUTO_STARTUP = INTEGRATION_PROPERTIES_PREFIX + "endpoints.noAutoStartup";
/**
* Whether {@link org.springframework.beans.factory.config.BeanPostProcessor}s should process beans registered at runtime.
* Will be removed in 5.1.
*/
public static final String POST_PROCESS_DYNAMIC_BEANS = INTEGRATION_PROPERTIES_PREFIX + "postProcessDynamicBeans";
private static Properties defaults;
static {

View File

@@ -21,10 +21,9 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.springframework.util.Assert;
/**
@@ -117,41 +116,13 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
return true;
}
catch (Exception e) {
throw wrapExceptionIfNecessary(message, e);
throw IntegrationUtils.wrapInDeliveryExceptionIfNecessary(message,
() -> "Dispatcher failed to deliver Message", e);
}
}
return false;
}
/**
* If the exception is not a {@link MessagingException} or does not have a
* {@link MessagingException#getFailedMessage() failedMessage}, wrap it in a new
* {@link MessagingException} with the message. There is some inconsistency here in
* that {@link MessagingException}s are wrapped in a {@link MessagingException} whereas
* {@link Exception}s are wrapped in {@link MessageDeliveryException}. It is retained
* for backwards compatibility and will be resolved in 5.1.
* It also does not wrap other {@link RuntimeException}s.
* TODO: Remove this in favor of
* {@code #wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception)} in 5.1.
* @param message the message.
* @param e the exception.
* @return the wrapper, if necessary, or the original exception.
* @deprecated in favor of
* {@code IntegrationUtils#wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception)}
*/
@Deprecated
protected RuntimeException wrapExceptionIfNecessary(Message<?> message, Exception e) {
RuntimeException runtimeException = (e instanceof RuntimeException)
? (RuntimeException) e
: new MessageDeliveryException(message,
"Dispatcher failed to deliver Message.", e);
if (e instanceof MessagingException &&
((MessagingException) e).getFailedMessage() == null) {
runtimeException = new MessagingException(message, "Dispatcher failed to deliver Message", e);
}
return runtimeException;
}
@Override
public String toString() {
return this.getClass().getSimpleName() + " with handlers: " + this.handlers.toString();

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.concurrent.Executor;
import org.springframework.integration.MessageDispatchingException;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessageHandler;
@@ -145,8 +146,8 @@ public class UnicastingDispatcher extends AbstractDispatcher {
success = true; // we have a winner.
}
catch (Exception e) {
@SuppressWarnings("deprecation")
RuntimeException runtimeException = wrapExceptionIfNecessary(message, e);
RuntimeException runtimeException = IntegrationUtils.wrapInDeliveryExceptionIfNecessary(message,
() -> "Dispatcher failed to deliver Message", e);
exceptions.add(runtimeException);
this.handleExceptions(exceptions, message, !handlerIterator.hasNext());
}

View File

@@ -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.
@@ -135,14 +135,12 @@ public class PollingConsumer extends AbstractPollingEndpoint implements Integrat
if (!CollectionUtils.isEmpty(interceptorStack)) {
triggerAfterMessageHandled(theMessage, ex, interceptorStack);
}
// TODO: In 5.1 remove this; adding the failed message to the text is redundant
final Message<?> messageForText = theMessage;
throw IntegrationUtils.wrapInDeliveryExceptionIfNecessary(theMessage,
() -> "Failed to handle " + messageForText + " to " + this + " in " + this.handler, ex);
() -> "Failed to handle message to " + this + " in " + this.handler, ex);
}
catch (Error ex) { //NOSONAR - ok, we re-throw below
if (!CollectionUtils.isEmpty(interceptorStack)) {
String description = "Failed to handle " + theMessage + " to " + this + " in " + this.handler;
String description = "Failed to handle message to " + this + " in " + this.handler;
triggerAfterMessageHandled(theMessage,
new MessageDeliveryException(theMessage, description, ex),
interceptorStack);

View File

@@ -6,4 +6,3 @@ spring.integration.messagingTemplate.throwExceptionOnLateReply=false
# Defaults to MessageHeaders.ID and MessageHeaders.TIMESTAMP
spring.integration.readOnly.headers=
spring.integration.endpoints.noAutoStartup=
spring.integration.postProcessDynamicBeans=false