4343import java .util .Set ;
4444import java .util .concurrent .CountDownLatch ;
4545import java .util .concurrent .ExecutionException ;
46+ import java .util .concurrent .Executors ;
4647import java .util .concurrent .Future ;
4748import java .util .concurrent .TimeUnit ;
4849import java .util .concurrent .atomic .AtomicBoolean ;
6061import org .springframework .beans .factory .BeanFactory ;
6162import org .springframework .core .serializer .DefaultDeserializer ;
6263import org .springframework .core .serializer .DefaultSerializer ;
63- import org .springframework .core .task .AsyncTaskExecutor ;
64- import org .springframework .core .task .SimpleAsyncTaskExecutor ;
6564import org .springframework .expression .EvaluationContext ;
6665import org .springframework .expression .Expression ;
6766import org .springframework .expression .spel .standard .SpelExpressionParser ;
@@ -91,8 +90,6 @@ public class TcpOutboundGatewayTests {
9190
9291 private static final Log logger = LogFactory .getLog (TcpOutboundGatewayTests .class );
9392
94- private AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor ();
95-
9693 @ ClassRule
9794 public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest ();
9895
@@ -104,13 +101,13 @@ public class TcpOutboundGatewayTests {
104101 public void testGoodNetSingle () throws Exception {
105102 final CountDownLatch latch = new CountDownLatch (1 );
106103 final AtomicBoolean done = new AtomicBoolean ();
107- final AtomicReference <ServerSocket > serverSocket = new AtomicReference <>();
108- this . executor .execute (() -> {
104+ final AtomicReference <ServerSocket > serverSocket = new AtomicReference <ServerSocket >();
105+ Executors . newSingleThreadExecutor () .execute (() -> {
109106 try {
110107 ServerSocket server = ServerSocketFactory .getDefault ().createServerSocket (0 , 100 );
111108 serverSocket .set (server );
112109 latch .countDown ();
113- List <Socket > sockets = new ArrayList <>();
110+ List <Socket > sockets = new ArrayList <Socket >();
114111 int i = 0 ;
115112 while (true ) {
116113 Socket socket = server .accept ();
@@ -168,8 +165,8 @@ public void testGoodNetSingle() throws Exception {
168165 public void testGoodNetMultiplex () throws Exception {
169166 final CountDownLatch latch = new CountDownLatch (1 );
170167 final AtomicBoolean done = new AtomicBoolean ();
171- final AtomicReference <ServerSocket > serverSocket = new AtomicReference <>();
172- this . executor .execute (() -> {
168+ final AtomicReference <ServerSocket > serverSocket = new AtomicReference <ServerSocket >();
169+ Executors . newSingleThreadExecutor () .execute (() -> {
173170 try {
174171 ServerSocket server = ServerSocketFactory .getDefault ().createServerSocket (0 , 10 );
175172 serverSocket .set (server );
@@ -223,8 +220,8 @@ public void testGoodNetMultiplex() throws Exception {
223220 public void testGoodNetTimeout () throws Exception {
224221 final CountDownLatch latch = new CountDownLatch (1 );
225222 final AtomicBoolean done = new AtomicBoolean ();
226- final AtomicReference <ServerSocket > serverSocket = new AtomicReference <>();
227- this . executor .execute (() -> {
223+ final AtomicReference <ServerSocket > serverSocket = new AtomicReference <ServerSocket >();
224+ Executors . newSingleThreadExecutor () .execute (() -> {
228225 try {
229226 ServerSocket server = ServerSocketFactory .getDefault ().createServerSocket (0 );
230227 serverSocket .set (server );
@@ -263,12 +260,12 @@ public void testGoodNetTimeout() throws Exception {
263260 Future <Integer >[] results = (Future <Integer >[]) new Future <?>[2 ];
264261 for (int i = 0 ; i < 2 ; i ++) {
265262 final int j = i ;
266- results [j ] = (this . executor .submit (() -> {
263+ results [j ] = (Executors . newSingleThreadExecutor () .submit (() -> {
267264 gateway .handleMessage (MessageBuilder .withPayload ("Test" + j ).build ());
268265 return 0 ;
269266 }));
270267 }
271- Set <String > replies = new HashSet <>();
268+ Set <String > replies = new HashSet <String >();
272269 int timeouts = 0 ;
273270 for (int i = 0 ; i < 2 ; i ++) {
274271 try {
@@ -347,7 +344,7 @@ private void testGoodNetGWTimeoutGuts(final int port, AbstractClientConnectionFa
347344 final AtomicReference <String > lastReceived = new AtomicReference <String >();
348345 final CountDownLatch serverLatch = new CountDownLatch (2 );
349346
350- this . executor .execute (() -> {
347+ Executors . newSingleThreadExecutor () .execute (() -> {
351348 try {
352349 latch .countDown ();
353350 int i = 0 ;
@@ -401,7 +398,7 @@ private void testGoodNetGWTimeoutGuts(final int port, AbstractClientConnectionFa
401398
402399 for (int i = 0 ; i < 2 ; i ++) {
403400 final int j = i ;
404- results [j ] = (this . executor .submit (() -> {
401+ results [j ] = (Executors . newSingleThreadExecutor () .submit (() -> {
405402 gateway .handleMessage (MessageBuilder .withPayload ("Test" + j ).build ());
406403 return j ;
407404 }));
@@ -445,7 +442,7 @@ public void testCachingFailover() throws Exception {
445442 final AtomicBoolean done = new AtomicBoolean ();
446443 final CountDownLatch serverLatch = new CountDownLatch (1 );
447444
448- this . executor .execute (() -> {
445+ Executors . newSingleThreadExecutor () .execute (() -> {
449446 try {
450447 ServerSocket server = ServerSocketFactory .getDefault ().createServerSocket (0 );
451448 serverSocket .set (server );
@@ -520,12 +517,12 @@ public void testCachingFailover() throws Exception {
520517
521518 @ Test
522519 public void testFailoverCached () throws Exception {
523- final AtomicReference <ServerSocket > serverSocket = new AtomicReference <>();
520+ final AtomicReference <ServerSocket > serverSocket = new AtomicReference <ServerSocket >();
524521 final CountDownLatch latch = new CountDownLatch (1 );
525522 final AtomicBoolean done = new AtomicBoolean ();
526523 final CountDownLatch serverLatch = new CountDownLatch (1 );
527524
528- this . executor .execute (() -> {
525+ Executors . newSingleThreadExecutor () .execute (() -> {
529526 try {
530527 ServerSocket server = ServerSocketFactory .getDefault ().createServerSocket (0 );
531528 serverSocket .set (server );
@@ -670,11 +667,11 @@ private void testGWPropagatesSocketCloseGuts(final int port, AbstractClientConne
670667 final ServerSocket server ) throws Exception {
671668 final CountDownLatch latch = new CountDownLatch (1 );
672669 final AtomicBoolean done = new AtomicBoolean ();
673- final AtomicReference <String > lastReceived = new AtomicReference <>();
670+ final AtomicReference <String > lastReceived = new AtomicReference <String >();
674671 final CountDownLatch serverLatch = new CountDownLatch (1 );
675672
676- this . executor .execute (() -> {
677- List <Socket > sockets = new ArrayList <>();
673+ Executors . newSingleThreadExecutor () .execute (() -> {
674+ List <Socket > sockets = new ArrayList <Socket >();
678675 try {
679676 latch .countDown ();
680677 while (!done .get ()) {
@@ -796,8 +793,8 @@ private void testGWPropagatesSocketTimeoutGuts(final int port, AbstractClientCon
796793 final CountDownLatch latch = new CountDownLatch (1 );
797794 final AtomicBoolean done = new AtomicBoolean ();
798795
799- this . executor .execute (() -> {
800- List <Socket > sockets = new ArrayList <>();
796+ Executors . newSingleThreadExecutor () .execute (() -> {
797+ List <Socket > sockets = new ArrayList <Socket >();
801798 try {
802799 latch .countDown ();
803800 while (!done .get ()) {
0 commit comments