[
https://issues.apache.org/jira/browse/SSHD-219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13600076#comment-13600076
]
Mark Peters commented on SSHD-219:
----------------------------------
This exact same problem can be found in Mina's DefaultIoFuture, but I'm using
SSHD, not Mina, so I reported it here.
The workaround is to always use a timeout value.
> DefaultSshFuture.awaitUninterruptibly() uses incorrect timeout
> --------------------------------------------------------------
>
> Key: SSHD-219
> URL: https://issues.apache.org/jira/browse/SSHD-219
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 0.8.0
> Reporter: Mark Peters
>
> DefaultSshFuture.awaitInterruptibly() works by setting a timeout of
> Long.MAX_VALUE. When you add this to System.currentTimeMillis(), you get a
> time very much in the past, since the value wraps to the negatives.
> Later, to detect timeout, await0() does this upon being woken up:
> if (ready) {
> return true;
> } else {
> if (endTime < System.currentTimeMillis()) { //THIS WILL ALWAYS BE TRUE
> return ready;
> }
> }
> Thus the ready check, which prevents spurious wakeups, never prevents
> spurious wakeups in the case that no timeout is specified.
> To fix this, endTime itself could simply be set to Long.MAX_VALUE rather than
> ADDING Long.MAX_VALUE to the current time.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira