Skip to content

Commit 62e46c9

Browse files
garyrussellartembilan
authored andcommitted
Remove use of deprecated ChannelInterceptorAdapter
Deprecated in favor of default methods on `ChannelInterceptor`. * Fix race in RouterConcurrencyTest; no assertion on executor shutdown; increase time. # Conflicts: # spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpChannelParserTests.java
1 parent 8e1dbdf commit 62e46c9

File tree

24 files changed

+97
-109
lines changed

24 files changed

+97
-109
lines changed

spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpChannelParserTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ private void checkExtract(AbstractAmqpChannel channel) {
122122
}
123123

124124
private static class TestInterceptor implements ChannelInterceptor {
125-
126125
}
127126

128127
}

spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/MessageSelectingInterceptor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 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.
@@ -23,16 +23,17 @@
2323
import org.springframework.messaging.Message;
2424
import org.springframework.messaging.MessageChannel;
2525
import org.springframework.messaging.MessageDeliveryException;
26-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
26+
import org.springframework.messaging.support.ChannelInterceptor;
2727

2828
/**
2929
* A {@link org.springframework.messaging.support.ChannelInterceptor ChannelInterceptor} that
3030
* delegates to a list of {@link MessageSelector MessageSelectors} to decide
3131
* whether a {@link Message} should be accepted on the {@link MessageChannel}.
3232
*
3333
* @author Mark Fisher
34+
* @author Gary Russell
3435
*/
35-
public class MessageSelectingInterceptor extends ChannelInterceptorAdapter {
36+
public class MessageSelectingInterceptor implements ChannelInterceptor {
3637

3738
private final List<MessageSelector> selectors;
3839

spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2016 the original author or authors.
2+
* Copyright 2015-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.
@@ -21,7 +21,7 @@
2121
import org.springframework.messaging.MessageChannel;
2222
import org.springframework.messaging.MessageHandler;
2323
import org.springframework.messaging.MessageHeaders;
24-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
24+
import org.springframework.messaging.support.ChannelInterceptor;
2525
import org.springframework.messaging.support.ExecutorChannelInterceptor;
2626

2727
/**
@@ -51,7 +51,7 @@
5151
* @since 4.2
5252
*/
5353
public abstract class ThreadStatePropagationChannelInterceptor<S>
54-
extends ChannelInterceptorAdapter implements ExecutorChannelInterceptor {
54+
implements ChannelInterceptor, ExecutorChannelInterceptor {
5555

5656
@Override
5757
public final Message<?> preSend(Message<?> message, MessageChannel channel) {

spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/WireTap.java

Lines changed: 2 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.
@@ -32,7 +32,6 @@
3232
import org.springframework.messaging.Message;
3333
import org.springframework.messaging.MessageChannel;
3434
import org.springframework.messaging.support.ChannelInterceptor;
35-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
3635
import org.springframework.util.Assert;
3736

3837
/**
@@ -44,8 +43,7 @@
4443
* @author Artem Bilan
4544
*/
4645
@ManagedResource
47-
public class WireTap extends ChannelInterceptorAdapter
48-
implements Lifecycle, VetoCapableInterceptor, BeanFactoryAware {
46+
public class WireTap implements ChannelInterceptor, Lifecycle, VetoCapableInterceptor, BeanFactoryAware {
4947

5048
private static final Log logger = LogFactory.getLog(WireTap.class);
5149

spring-integration-core/src/test/java/org/springframework/integration/channel/ExecutorChannelTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.springframework.messaging.MessageChannel;
4747
import org.springframework.messaging.MessageDeliveryException;
4848
import org.springframework.messaging.MessageHandler;
49-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
5049
import org.springframework.messaging.support.ExecutorChannelInterceptor;
5150
import org.springframework.messaging.support.GenericMessage;
5251
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
@@ -262,8 +261,7 @@ public void handleMessage(Message<?> message) {
262261
}
263262
}
264263

265-
private static class BeforeHandleInterceptor extends ChannelInterceptorAdapter
266-
implements ExecutorChannelInterceptor {
264+
private static class BeforeHandleInterceptor implements ExecutorChannelInterceptor {
267265

268266
private final AtomicInteger counter = new AtomicInteger();
269267

spring-integration-core/src/test/java/org/springframework/integration/channel/config/ChannelParserTests.java

Lines changed: 3 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.
@@ -55,7 +55,7 @@
5555
import org.springframework.messaging.MessageHeaders;
5656
import org.springframework.messaging.PollableChannel;
5757
import org.springframework.messaging.converter.MessageConverter;
58-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
58+
import org.springframework.messaging.support.ChannelInterceptor;
5959
import org.springframework.messaging.support.GenericMessage;
6060
import org.springframework.test.annotation.DirtiesContext;
6161
import org.springframework.test.context.ContextConfiguration;
@@ -290,7 +290,7 @@ public void testPriorityChannelWithIntegerDatatypeEnforced() {
290290
assertTrue(threwException);
291291
}
292292

293-
public static class TestInterceptor extends ChannelInterceptorAdapter {
293+
public static class TestInterceptor implements ChannelInterceptor {
294294

295295
@Override
296296
public Message<?> preSend(Message<?> message, MessageChannel channel) {

spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ChannelInterceptorTests.java

Lines changed: 17 additions & 12 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.
@@ -46,7 +46,6 @@
4646
import org.springframework.messaging.MessageChannel;
4747
import org.springframework.messaging.MessageHandler;
4848
import org.springframework.messaging.support.ChannelInterceptor;
49-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
5049
import org.springframework.messaging.support.ExecutorChannelInterceptor;
5150
import org.springframework.messaging.support.GenericMessage;
5251
import org.springframework.util.StringUtils;
@@ -55,6 +54,7 @@
5554
* @author Mark Fisher
5655
* @author Oleg Zhurakousky
5756
* @author Artem Bilan
57+
* @author Gary Russell
5858
*/
5959
public class ChannelInterceptorTests {
6060

@@ -94,7 +94,8 @@ public void testPreSendInterceptorReturnsNull() {
9494
@Test
9595
public void testPostSendInterceptorWithSentMessage() {
9696
final AtomicBoolean invoked = new AtomicBoolean(false);
97-
channel.addInterceptor(new ChannelInterceptorAdapter() {
97+
channel.addInterceptor(new ChannelInterceptor() {
98+
9899
@Override
99100
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
100101
assertNotNull(message);
@@ -103,6 +104,7 @@ public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
103104
assertTrue(sent);
104105
invoked.set(true);
105106
}
107+
106108
});
107109
channel.send(new GenericMessage<String>("test"));
108110
assertTrue(invoked.get());
@@ -113,7 +115,8 @@ public void testPostSendInterceptorWithUnsentMessage() {
113115
final AtomicInteger invokedCounter = new AtomicInteger(0);
114116
final AtomicInteger sentCounter = new AtomicInteger(0);
115117
final QueueChannel singleItemChannel = new QueueChannel(1);
116-
singleItemChannel.addInterceptor(new ChannelInterceptorAdapter() {
118+
singleItemChannel.addInterceptor(new ChannelInterceptor() {
119+
117120
@Override
118121
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
119122
assertNotNull(message);
@@ -124,6 +127,7 @@ public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
124127
}
125128
invokedCounter.incrementAndGet();
126129
}
130+
127131
});
128132
assertEquals(0, invokedCounter.get());
129133
assertEquals(0, sentCounter.get());
@@ -206,7 +210,8 @@ public void testPreReceiveInterceptorReturnsFalse() {
206210
public void testPostReceiveInterceptor() {
207211
final AtomicInteger invokedCount = new AtomicInteger();
208212
final AtomicInteger messageCount = new AtomicInteger();
209-
channel.addInterceptor(new ChannelInterceptorAdapter() {
213+
channel.addInterceptor(new ChannelInterceptor() {
214+
210215
@Override
211216
public Message<?> postReceive(Message<?> message, MessageChannel channel) {
212217
assertNotNull(channel);
@@ -217,6 +222,7 @@ public Message<?> postReceive(Message<?> message, MessageChannel channel) {
217222
invokedCount.incrementAndGet();
218223
return message;
219224
}
225+
220226
});
221227
channel.receive(0);
222228
assertEquals(1, invokedCount.get());
@@ -295,7 +301,7 @@ public void testPollingConsumerWithExecutorInterceptor() throws InterruptedExcep
295301
testApplicationContext.close();
296302
}
297303

298-
public static class PreSendReturnsMessageInterceptor extends ChannelInterceptorAdapter {
304+
public static class PreSendReturnsMessageInterceptor implements ChannelInterceptor {
299305
private String foo;
300306

301307
private static AtomicInteger counter = new AtomicInteger();
@@ -329,7 +335,7 @@ public void afterSendCompletion(Message<?> message, MessageChannel channel, bool
329335
}
330336

331337

332-
private static class PreSendReturnsNullInterceptor extends ChannelInterceptorAdapter {
338+
private static class PreSendReturnsNullInterceptor implements ChannelInterceptor {
333339

334340
private static AtomicInteger counter = new AtomicInteger();
335341

@@ -349,7 +355,7 @@ public Message<?> preSend(Message<?> message, MessageChannel channel) {
349355
}
350356
}
351357

352-
private static class AfterCompletionTestInterceptor extends ChannelInterceptorAdapter {
358+
private static class AfterCompletionTestInterceptor implements ChannelInterceptor {
353359

354360
private final AtomicInteger counter = new AtomicInteger();
355361

@@ -391,7 +397,7 @@ public void afterSendCompletion(Message<?> message, MessageChannel channel, bool
391397

392398
}
393399

394-
private static class PreReceiveReturnsTrueInterceptor extends ChannelInterceptorAdapter {
400+
private static class PreReceiveReturnsTrueInterceptor implements ChannelInterceptor {
395401

396402
private final AtomicInteger counter = new AtomicInteger();
397403

@@ -432,7 +438,7 @@ public void afterReceiveCompletion(Message<?> message, MessageChannel channel, E
432438
}
433439

434440

435-
private static class PreReceiveReturnsFalseInterceptor extends ChannelInterceptorAdapter {
441+
private static class PreReceiveReturnsFalseInterceptor implements ChannelInterceptor {
436442

437443
private static AtomicInteger counter = new AtomicInteger();
438444

@@ -448,8 +454,7 @@ public boolean preReceive(MessageChannel channel) {
448454

449455
}
450456

451-
private static class TestExecutorInterceptor extends ChannelInterceptorAdapter
452-
implements ExecutorChannelInterceptor {
457+
private static class TestExecutorInterceptor implements ExecutorChannelInterceptor {
453458

454459
TestExecutorInterceptor() {
455460
super();

spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.springframework.messaging.Message;
4242
import org.springframework.messaging.MessageChannel;
4343
import org.springframework.messaging.support.ChannelInterceptor;
44-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
4544
import org.springframework.test.context.ContextConfiguration;
4645
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
4746

@@ -160,7 +159,7 @@ public void testDynamicMessageChannelBeanWithAutoGlobalChannelInterceptor() {
160159
assertThat(channelInterceptors.get(0), instanceOf(SampleInterceptor.class));
161160
}
162161

163-
public static class SampleInterceptor extends ChannelInterceptorAdapter {
162+
public static class SampleInterceptor implements ChannelInterceptor {
164163

165164
private String testIdentifier;
166165

@@ -172,17 +171,21 @@ public void setTestIdentifier(String testIdentifier) {
172171
this.testIdentifier = testIdentifier;
173172
}
174173

174+
@Override
175175
public Message<?> postReceive(Message<?> message, MessageChannel channel) {
176176
return null;
177177
}
178178

179+
@Override
179180
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
180181
}
181182

183+
@Override
182184
public boolean preReceive(MessageChannel channel) {
183185
return false;
184186
}
185187

188+
@Override
186189
public Message<?> preSend(Message<?> message, MessageChannel channel) {
187190
return null;
188191
}

spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-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.
@@ -32,7 +32,6 @@
3232
import org.springframework.messaging.Message;
3333
import org.springframework.messaging.MessageChannel;
3434
import org.springframework.messaging.support.ChannelInterceptor;
35-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
3635
import org.springframework.test.context.ContextConfiguration;
3736
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3837

@@ -71,7 +70,7 @@ public void testImplicit() {
7170
assertThat(bazInterceptors.get(1), anyOf(instanceOf(WireTap.class), instanceOf(Interceptor1.class)));
7271
}
7372

74-
public static class Interceptor1 extends ChannelInterceptorAdapter implements VetoCapableInterceptor {
73+
public static class Interceptor1 implements ChannelInterceptor, VetoCapableInterceptor {
7574

7675
private MessageChannel channel;
7776

@@ -109,7 +108,7 @@ public boolean shouldIntercept(String beanName, ChannelInterceptorAware channel)
109108

110109
}
111110

112-
public static class Interceptor2 extends ChannelInterceptorAdapter implements VetoCapableInterceptor {
111+
public static class Interceptor2 implements ChannelInterceptor, VetoCapableInterceptor {
113112

114113
private MessageChannel channel;
115114

spring-integration-core/src/test/java/org/springframework/integration/config/TestChannelInterceptor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 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.
@@ -20,12 +20,13 @@
2020

2121
import org.springframework.messaging.Message;
2222
import org.springframework.messaging.MessageChannel;
23-
import org.springframework.messaging.support.ChannelInterceptorAdapter;
23+
import org.springframework.messaging.support.ChannelInterceptor;
2424

2525
/**
2626
* @author Mark Fisher
27+
* @author Gary Russell
2728
*/
28-
public class TestChannelInterceptor extends ChannelInterceptorAdapter {
29+
public class TestChannelInterceptor implements ChannelInterceptor {
2930

3031
private final AtomicInteger sendCount = new AtomicInteger();
3132

0 commit comments

Comments
 (0)