Open mikebin opened 3 years ago
Adding the following before closing the Client
eliminates the exception, so maybe adding an example to the docs is all that's needed, unless this cleanup can be simplified at the code/API level.
client.terminatePushQuery(streamedQueryResult.queryID());
Row row = streamedQueryResult.poll();
while(row != null) {
row = streamedQueryResult.poll();
}
Describe the bug Java client
StreamedQueryResultImpl
class throws the following exception after executing a synchronous query and subsequently callingClient#close
:This does not actually cause any issues in query execution, but can be confusing for developers, especially since it's logged at
ERROR
level.To Reproduce Version: 0.18.0/6.2.0
Example app which reproduces the issue:
Expected behavior Clean shutdown, with no error logs.
Actual behaviour
Additional context Looking at the code for that
StreamedQueryResultImpl.java
, it appears to use an async subscription (PollableSubscriber) internally, even when polling.I’m assuming what’s happening is the user is closing the ksqlDB Client while the
PollableSubscriber
is still active, and that leads to the exception. Is there a way to gracefully complete/close theStreamedQueryResult
so that thePollableSubscriber
terminates before theClient
is closed, or is there a different way the code should be written which would trigger a proper automatic cleanup?I see a method in the base class
BufferedPublisher#complete
which looks like it could stop the internal subscriber, but not sure it’s expected for end-users to call that method directly.