Skip to content

Commit b940e38

Browse files
garyrussellartembilan
authored andcommitted
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
1 parent 27318c7 commit b940e38

File tree

16 files changed

+33
-314
lines changed

16 files changed

+33
-314
lines changed

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ subprojects { subproject ->
122122
junitVintageVersion = '5.1.0'
123123
jythonVersion = '2.5.3'
124124
kryoShadedVersion = '3.0.3'
125-
log4jVersion = '2.10.0'
125+
log4jVersion = '2.11.0'
126126
micrometerVersion = '1.0.3'
127127
mockitoVersion = '2.11.0'
128128
mysqlVersion = '6.0.6'
@@ -141,7 +141,7 @@ subprojects { subproject ->
141141
springSecurityVersion = '5.1.0.BUILD-SNAPSHOT'
142142
springSocialTwitterVersion = '1.1.2.RELEASE'
143143
springRetryVersion = '1.2.2.RELEASE'
144-
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.5.BUILD-SNAPSHOT'
144+
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.1.0.BUILD-SNAPSHOT'
145145
springWsVersion = '3.0.1.RELEASE'
146146
tomcatVersion = "8.5.23"
147147
xmlUnitVersion = '1.6'
@@ -291,7 +291,6 @@ project('spring-integration-test-support') {
291291
compile "org.springframework:spring-messaging:$springVersion"
292292
compile "org.springframework:spring-test:$springVersion"
293293
compile ("org.apache.logging.log4j:log4j-core:$log4jVersion" , optional)
294-
compile ('log4j:log4j:1.2.17', optional)
295294
}
296295
}
297296

spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.Map.Entry;
26-
import java.util.Properties;
2726
import java.util.Set;
2827

2928
import org.apache.commons.logging.Log;
@@ -39,8 +38,6 @@
3938
import org.springframework.integration.channel.ChannelInterceptorAware;
4039
import org.springframework.integration.channel.interceptor.GlobalChannelInterceptorWrapper;
4140
import org.springframework.integration.channel.interceptor.VetoCapableInterceptor;
42-
import org.springframework.integration.context.IntegrationContextUtils;
43-
import org.springframework.integration.context.IntegrationProperties;
4441
import org.springframework.integration.support.utils.PatternMatchUtils;
4542
import org.springframework.messaging.support.ChannelInterceptor;
4643
import org.springframework.util.Assert;
@@ -105,12 +102,7 @@ public void afterSingletonsInstantiated() {
105102
}
106103
}
107104

108-
// TODO Remove this logic in 5.1
109-
Properties integrationProperties = IntegrationContextUtils.getIntegrationProperties(this.beanFactory);
110-
111-
this.singletonsInstantiated =
112-
Boolean.parseBoolean(integrationProperties.getProperty(
113-
IntegrationProperties.POST_PROCESS_DYNAMIC_BEANS));
105+
this.singletonsInstantiated = true;
114106
}
115107

116108
@Override

spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationProperties.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ public final class IntegrationProperties {
7777
*/
7878
public static final String ENDPOINTS_NO_AUTO_STARTUP = INTEGRATION_PROPERTIES_PREFIX + "endpoints.noAutoStartup";
7979

80-
/**
81-
* Whether {@link org.springframework.beans.factory.config.BeanPostProcessor}s should process beans registered at runtime.
82-
* Will be removed in 5.1.
83-
*/
84-
public static final String POST_PROCESS_DYNAMIC_BEANS = INTEGRATION_PROPERTIES_PREFIX + "postProcessDynamicBeans";
85-
86-
8780
private static Properties defaults;
8881

8982
static {

spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AbstractDispatcher.java

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
import org.apache.commons.logging.Log;
2222
import org.apache.commons.logging.LogFactory;
2323

24+
import org.springframework.integration.support.utils.IntegrationUtils;
2425
import org.springframework.messaging.Message;
25-
import org.springframework.messaging.MessageDeliveryException;
2626
import org.springframework.messaging.MessageHandler;
27-
import org.springframework.messaging.MessagingException;
2827
import org.springframework.util.Assert;
2928

3029
/**
@@ -117,41 +116,13 @@ protected boolean tryOptimizedDispatch(Message<?> message) {
117116
return true;
118117
}
119118
catch (Exception e) {
120-
throw wrapExceptionIfNecessary(message, e);
119+
throw IntegrationUtils.wrapInDeliveryExceptionIfNecessary(message,
120+
() -> "Dispatcher failed to deliver Message", e);
121121
}
122122
}
123123
return false;
124124
}
125125

126-
/**
127-
* If the exception is not a {@link MessagingException} or does not have a
128-
* {@link MessagingException#getFailedMessage() failedMessage}, wrap it in a new
129-
* {@link MessagingException} with the message. There is some inconsistency here in
130-
* that {@link MessagingException}s are wrapped in a {@link MessagingException} whereas
131-
* {@link Exception}s are wrapped in {@link MessageDeliveryException}. It is retained
132-
* for backwards compatibility and will be resolved in 5.1.
133-
* It also does not wrap other {@link RuntimeException}s.
134-
* TODO: Remove this in favor of
135-
* {@code #wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception)} in 5.1.
136-
* @param message the message.
137-
* @param e the exception.
138-
* @return the wrapper, if necessary, or the original exception.
139-
* @deprecated in favor of
140-
* {@code IntegrationUtils#wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception)}
141-
*/
142-
@Deprecated
143-
protected RuntimeException wrapExceptionIfNecessary(Message<?> message, Exception e) {
144-
RuntimeException runtimeException = (e instanceof RuntimeException)
145-
? (RuntimeException) e
146-
: new MessageDeliveryException(message,
147-
"Dispatcher failed to deliver Message.", e);
148-
if (e instanceof MessagingException &&
149-
((MessagingException) e).getFailedMessage() == null) {
150-
runtimeException = new MessagingException(message, "Dispatcher failed to deliver Message", e);
151-
}
152-
return runtimeException;
153-
}
154-
155126
@Override
156127
public String toString() {
157128
return this.getClass().getSimpleName() + " with handlers: " + this.handlers.toString();

spring-integration-core/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.concurrent.Executor;
2323

2424
import org.springframework.integration.MessageDispatchingException;
25+
import org.springframework.integration.support.utils.IntegrationUtils;
2526
import org.springframework.messaging.Message;
2627
import org.springframework.messaging.MessageDeliveryException;
2728
import org.springframework.messaging.MessageHandler;
@@ -145,8 +146,8 @@ private boolean doDispatch(Message<?> message) {
145146
success = true; // we have a winner.
146147
}
147148
catch (Exception e) {
148-
@SuppressWarnings("deprecation")
149-
RuntimeException runtimeException = wrapExceptionIfNecessary(message, e);
149+
RuntimeException runtimeException = IntegrationUtils.wrapInDeliveryExceptionIfNecessary(message,
150+
() -> "Dispatcher failed to deliver Message", e);
150151
exceptions.add(runtimeException);
151152
this.handleExceptions(exceptions, message, !handlerIterator.hasNext());
152153
}

spring-integration-core/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java

Lines changed: 3 additions & 5 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.
@@ -135,14 +135,12 @@ protected void handleMessage(Message<?> message) {
135135
if (!CollectionUtils.isEmpty(interceptorStack)) {
136136
triggerAfterMessageHandled(theMessage, ex, interceptorStack);
137137
}
138-
// TODO: In 5.1 remove this; adding the failed message to the text is redundant
139-
final Message<?> messageForText = theMessage;
140138
throw IntegrationUtils.wrapInDeliveryExceptionIfNecessary(theMessage,
141-
() -> "Failed to handle " + messageForText + " to " + this + " in " + this.handler, ex);
139+
() -> "Failed to handle message to " + this + " in " + this.handler, ex);
142140
}
143141
catch (Error ex) { //NOSONAR - ok, we re-throw below
144142
if (!CollectionUtils.isEmpty(interceptorStack)) {
145-
String description = "Failed to handle " + theMessage + " to " + this + " in " + this.handler;
143+
String description = "Failed to handle message to " + this + " in " + this.handler;
146144
triggerAfterMessageHandled(theMessage,
147145
new MessageDeliveryException(theMessage, description, ex),
148146
interceptorStack);

spring-integration-core/src/main/resources/META-INF/spring.integration.default.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ spring.integration.messagingTemplate.throwExceptionOnLateReply=false
66
# Defaults to MessageHeaders.ID and MessageHeaders.TIMESTAMP
77
spring.integration.readOnly.headers=
88
spring.integration.endpoints.noAutoStartup=
9-
spring.integration.postProcessDynamicBeans=false

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
import static org.junit.Assert.assertNotNull;
2323
import static org.junit.Assert.assertThat;
2424

25-
import org.apache.log4j.Level;
26-
import org.apache.log4j.LogManager;
27-
import org.junit.AfterClass;
28-
import org.junit.BeforeClass;
2925
import org.junit.Test;
3026
import org.junit.runner.RunWith;
3127

@@ -67,20 +63,6 @@ public class InterceptedSharedConnectionTests {
6763
@Autowired
6864
Listener listener;
6965

70-
private static Level existingLogLevel;
71-
72-
// temporary hooks to investigate CI failures
73-
@BeforeClass
74-
public static void setup() {
75-
existingLogLevel = LogManager.getLogger("org.springframework.integration").getLevel();
76-
LogManager.getLogger("org.springframework.integration").setLevel(Level.DEBUG);
77-
}
78-
79-
@AfterClass
80-
public static void tearDown() {
81-
LogManager.getLogger("org.springframework.integration").setLevel(existingLogLevel);
82-
}
83-
8466
/**
8567
* Tests a loopback. The client-side outbound adapter sends a message over
8668
* a connection from the client connection factory; the server side

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcExecutorTests.java

Lines changed: 4 additions & 3 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.
@@ -27,7 +27,8 @@
2727

2828
import javax.sql.DataSource;
2929

30-
import org.apache.log4j.Logger;
30+
import org.apache.commons.logging.Log;
31+
import org.apache.commons.logging.LogFactory;
3132
import org.junit.Test;
3233

3334
import org.springframework.beans.DirectFieldAccessor;
@@ -52,7 +53,7 @@
5253
*/
5354
public class StoredProcExecutorTests {
5455

55-
private static final Logger LOGGER = Logger.getLogger(StoredProcExecutorTests.class);
56+
private static final Log LOGGER = LogFactory.getLog(StoredProcExecutorTests.class);
5657

5758
@Test
5859
public void testStoredProcExecutorWithNullDataSource() {

spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/PipelineJmsTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626

2727
import org.apache.commons.logging.Log;
2828
import org.apache.commons.logging.LogFactory;
29-
import org.apache.log4j.Level;
30-
import org.apache.log4j.LogManager;
3129
import org.junit.After;
32-
import org.junit.Before;
3330
import org.junit.Rule;
3431
import org.junit.Test;
3532

@@ -54,11 +51,6 @@ public class PipelineJmsTests extends ActiveMQMultiContextTests {
5451
@Rule
5552
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
5653

57-
@Before
58-
public void setLogLevel() {
59-
LogManager.getLogger(getClass()).setLevel(Level.INFO);
60-
}
61-
6254
@After
6355
public void tearDown() {
6456
this.executor.shutdownNow();

spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/PipelineNamedReplyQueuesJmsTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929

3030
import org.apache.commons.logging.Log;
3131
import org.apache.commons.logging.LogFactory;
32-
import org.apache.log4j.Level;
33-
import org.apache.log4j.LogManager;
3432
import org.junit.After;
35-
import org.junit.Before;
3633
import org.junit.Rule;
3734
import org.junit.Test;
3835

@@ -59,11 +56,6 @@ public class PipelineNamedReplyQueuesJmsTests extends ActiveMQMultiContextTests
5956
@Rule
6057
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
6158

62-
@Before
63-
public void setLogLevel() {
64-
LogManager.getLogger(getClass()).setLevel(Level.INFO);
65-
}
66-
6759
@After
6860
public void tearDown() {
6961
this.executor.shutdownNow();

spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static MBeanServerFactoryBean mBeanServer() {
250250

251251
@Bean
252252
public HazelcastInstance hazelcastInstance() {
253-
return Hazelcast.newHazelcastInstance(new Config().setProperty("hazelcast.logging.type", "log4j"));
253+
return Hazelcast.newHazelcastInstance(new Config().setProperty("hazelcast.logging.type", "slf4j"));
254254
}
255255

256256

0 commit comments

Comments
 (0)