From bac3565dfd6d4d7336dfac216490acb848b152cb Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 24 Jan 2019 09:59:12 -0500 Subject: [PATCH] GH-2714: Fix PollSkipAdvice Fixes https://github.com/spring-projects/spring-integration/issues/2714 Return null instead of false when poll skipped. --- .../integration/scheduling/PollSkipAdvice.java | 4 ++-- .../integration/endpoint/PollerAdviceTests.java | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/scheduling/PollSkipAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/scheduling/PollSkipAdvice.java index dfdd33175c..606d41b137 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/scheduling/PollSkipAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/scheduling/PollSkipAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 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. @@ -54,7 +54,7 @@ public class PollSkipAdvice implements MethodInterceptor { + this.pollSkipStrategy.getClass().getName() + ".skipPoll() returned true"); } - return Boolean.FALSE; + return null; } else { return invocation.proceed(); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java index 2a33423bfe..fa2fcafa2e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 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. @@ -34,6 +34,7 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -143,6 +144,10 @@ public class PollerAdviceTests { CountDownLatch latch = new CountDownLatch(1); adapter.setSource(new LocalSource(latch)); adapter.setTrigger(new OnlyOnceTrigger()); + AtomicBoolean ehCalled = new AtomicBoolean(); + adapter.setErrorHandler(t -> { + ehCalled.set(true); + }); configure(adapter); List adviceChain = new ArrayList<>(); SimplePollSkipStrategy skipper = new SimplePollSkipStrategy(); @@ -153,6 +158,7 @@ public class PollerAdviceTests { adapter.afterPropertiesSet(); adapter.start(); assertFalse(latch.await(10, TimeUnit.MILLISECONDS)); + assertFalse(ehCalled.get()); adapter.stop(); skipper.reset(); latch = new CountDownLatch(1);