-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Future<Void> method with @Gateway causes thread leak #3635
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
Comments
See similar discussion about I think this is that part which is missed from the logic and therefore it is not described in the docs. At a glance it does not make much sense to have a |
For now I schedule this for the next version since we never advertised support for |
Looks like Kotlin Will try to fix this shortly. |
Fixes spring-projects#3635 When `Future<Void>` & `Mono<Void>` is used as a messaging gateway return type, the application hangs out on this barrier which may lead to the out of memory eventually * Add support for the `Future<Void>` & `Mono<Void>` messaging gateway return type and ensure an asynchronous call for the `gateway.send(Message)` operation and its exception handling. In case of successful call, the `Future` is fulfilled with `null` and `Mono` is completed as empty
Fixes spring-projects#3635 When `Future<Void>` & `Mono<Void>` is used as a messaging gateway return type, the application hangs out on this barrier which may lead to the out of memory eventually * Add support for the `Future<Void>` & `Mono<Void>` messaging gateway return type and ensure an asynchronous call for the `gateway.send(Message)` operation and its exception handling. In case of successful call, the `Future` is fulfilled with `null` and `Mono` is completed as empty
* GH-3635: Add Future<Void> & Mono<Void> to gateway Fixes #3635 When `Future<Void>` & `Mono<Void>` is used as a messaging gateway return type, the application hangs out on this barrier which may lead to the out of memory eventually * Add support for the `Future<Void>` & `Mono<Void>` messaging gateway return type and ensure an asynchronous call for the `gateway.send(Message)` operation and its exception handling. In case of successful call, the `Future` is fulfilled with `null` and `Mono` is completed as empty * * Check for `void.class` as well in the `GatewayProxyFactoryBean.isVoidReturnType` * * Allow `Future<Void>` as a reply type of the gateway request-reply operation * * Fix Checkstyle violations * * Resolve `System.err.println()` in the test code * Add `Thread.currentThread.interrupt()` to the `InterruptedException` block in the test
In what version(s) of Spring Integration are you seeing this issue?
org.springframework.boot:spring-boot-starter-integration: '2.2.6.RELEASE'
Describe the bug
If response type is
Future<Void>
, the method with@Gateway
causes thread leak. New threads are constantly spawned without reusing or disposing. It was confirmed on thread dump I collected in my application. Even though each memory usage is quite small, threads being racked up will eventually lead OOM.I assume that this is happening because of no acknowledgement with Void.
However, there's a solution. It simply can be avoided by replacing it with
void send
along withExecutorService
in order to keep it asynchronous. (Non-blocking messaging is what I wanna do)e.g.
This is maybe a bug or should be described clearly in the docs if not a bug imhp.
To Reproduce
send(payload)
at a producer class.Have a consumer class which contains method like
As a result, threads spawned by that consumers stays in the lifetime of application apparently unless the application is restarted or so. Thus this will eventually lead OOM.
Expected behavior
Future<Void>
Or
ExecutorService
should be recommended.Sample
See above.
Thx in advance.
The text was updated successfully, but these errors were encountered: