IntelliJ reports the use of Reader.ready() as havi...
# coroutines
p
IntelliJ reports the use of Reader.ready() as having the potential to block and thus "inappropriate" in a suspend function. But the JavaDoc says: "This method returns true if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block." So that leaves me thinking IntelliJ is wrong (a bug). Does JetBrains know something that is not in the documentation perhaps?
e
It uses a very simply heuristic. If method throws
IOException
, then it is considered "blocking". You should file an issue to add exclusion for this case of IOException-throwing method that is not, in fact, blocking.\
p
That seems to say that I can ignore the warning and should expect my code to work unless the IOException needs to be excluded in coroutine code. I have filed the issue. My suspend function code is trying to do, essentially, ...`while(true) { if (!Reader.ready()) { delay(100L); print("got here") } else break }`but the "got here" never gets printed. Is that consistent with your understanding of the coroutine behavior without the issue being addressed?
e
The warning is orthogonal to whether your code works or not. Your reader impl probably does not implement the ready function if it does not work or you have a problem elsewhere.
p
Ok