-
Notifications
You must be signed in to change notification settings - Fork 337
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
improvement: add timeout to fix java version for sbt request #5715
improvement: add timeout to fix java version for sbt request #5715
Conversation
d85707f
to
52138d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one question
@@ -206,6 +208,8 @@ case class SbtBuildTool( | |||
shutdownBspServer(shellRunner).ignoreValue | |||
case _ => Future.successful(()) | |||
} | |||
.withTimeout(10, TimeUnit.SECONDS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS this the timeout of message requests in VS Code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like 15sec. But I also realised that this wasn't very smart, since if you'd press the restart
button after the timeout (which you always can do) it would simply shut down the sbt server. I fixed that now.
.asScala | ||
.flatMap { | ||
case Messages.SbtServerJavaHomeUpdate.restart => | ||
if (promise.isCompleted) restartSbtBuildServer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completing the promise will only happen after this future is finished, so this condition will always be false, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't think you're right. The promise is completed by (...).withTimeout(...)
, so a new future with await
inside. The original Future, won't get cancelled, 'cause you can't cancel futures in Scala, so this is the code that will be executed when the user chooses restart
after the timeout. (Which you can do in VSCode, 'cause the notifications are stored.) Am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you're right. I didn't think about the after 15 seconds part. Might be good to add some comments, since it doesn't seem easy to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
.asScala | ||
.flatMap { | ||
case Messages.SbtServerJavaHomeUpdate.restart => | ||
if (promise.isCompleted) restartSbtBuildServer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you're right. I didn't think about the after 15 seconds part. Might be good to add some comments, since it doesn't seem easy to follow.
b4c86be
to
6ff50be
Compare
No description provided.