Conversation
| int charsRead = in.read(buffer, 0, buffer.length); | ||
| if (charsRead < 0) throw new NetconfException("Input Stream has been closed during reading."); | ||
| rpcReply.append(buffer, 0, charsRead); | ||
| if (in.ready()) { |
There was a problem hiding this comment.
I think this is a bad idea. It looks to me it will end up in a tight loop burning CPU until timeout or the device sends some data.
There was a problem hiding this comment.
You are right. I have investigated a bit further and it seems like having a timeout control using another thread is a valid solution. I have implemented it, now all tests pass and hang issue seems resolved. However, as I don't have much experience with threads I will investigate this solution a bit more and commit later on.
Do you have any other idea or any objection?
There was a problem hiding this comment.
Without thinking about it too much, a CompletableFuture is probably what you want to be looking at, but there are no doubt other options.
There was a problem hiding this comment.
(Though there may well be a better way using NIO, but can’t remember the full context of this code off the top of my head , so unsure if it could easily be applied in this case)
No description provided.