Skip to content

ClassCastException from PollSkipAdvice #2714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cdombroski opened this issue Jan 24, 2019 · 5 comments
Closed

ClassCastException from PollSkipAdvice #2714

cdombroski opened this issue Jan 24, 2019 · 5 comments

Comments

@cdombroski
Copy link

Affects Version(s): 5.1.2


When using a PollSkipAdvice that is set to skipPolls, it causes a ClassCastException in AbstractPollingEndpoint. This is caused by the return Boolean.FALSE; on line 56 when the AbstractPollingEndpoint expects a Message or null.

2019-01-24 09:08:09.814 ERROR 8732 --- [ask-scheduler-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessagingException: nested exception is java.lang.ClassCastException: java.lang.Boolean cannot be cast to org.springframework.messaging.Message
at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:343)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$null$1(AbstractPollingEndpoint.java:277)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:57)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:55)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$createPoller$2(AbstractPollingEndpoint.java:274)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: java.lang.Boolean cannot be cast to org.springframework.messaging.Message
at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:329)
... 15 more

@garyrussell garyrussell self-assigned this Jan 24, 2019
@garyrussell garyrussell added this to the 5.1.3 milestone Jan 24, 2019
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Jan 24, 2019
Fixes spring-projects#2714

Return null instead of false when poll skipped.
@garyrussell
Copy link
Contributor

Thanks - strange that nobody reported this in 5 years - I guess people aren't using it (or are using a smart poller, which really superseded this functionality).

@cdombroski
Copy link
Author

It looks like a change in AbstractPollingEndpoint occurred about 4 months ago might have introduced this.

If you don't mind, could you point me to the documentation for the smart polling you mentioned? I'm using this to only poll a database when the process has leadership.

@garyrussell
Copy link
Contributor

garyrussell commented Jan 24, 2019

Ah - ok; thanks; yes, it's a regression.

See "Smart" Polling.

Version 4.2 introduced the AbstractMessageSourceAdvice. Any Advice objects in the advice-chain that subclass this class are applied only to the receive operation. Such classes implement the following methods:

  • beforeReceive(MessageSource<?> source) This method is called before the MessageSource.receive() method. It lets you examine and reconfigure the source. Returning false cancels this poll (similar to the PollSkipAdvice mentioned earlier).

artembilan pushed a commit that referenced this issue Jan 24, 2019
Fixes #2714

Return null instead of false when poll skipped.
@cdombroski
Copy link
Author

So, it looks like there's nothing out of the box to provide the functionality of PollSkipAdvice as a AbstractMessageSourceAdvice. It wouldn't take much to refactor the current class to do so, is this something that should/will be done in the future?

@garyrussell
Copy link
Contributor

Good point; yes, we should do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants