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
ConsoleReader should be blocking in sbt 1.4+ since System.in already is non-blocking #11061
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mergifyio backport master |
🟠 Waiting for conditions to match
|
BTW: I tested this with sbt
|
@Mergifyio backport 2.7.x |
🟠 Waiting for conditions to match
|
gmethvin
approved these changes
Dec 21, 2021
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.
Nice! Thanks for fixing this
✅ Backports have been created
|
✅ Backports have been created
|
Thanks Greg! |
mergify bot
added a commit
that referenced
this pull request
Dec 21, 2021
ConsoleReader should be blocking in sbt 1.4+ since System.in already is non-blocking (backport #11061)
mergify bot
added a commit
that referenced
this pull request
Dec 21, 2021
ConsoleReader should be blocking in sbt 1.4+ since System.in already is non-blocking (backport #11061)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #11032
In #9420 we made the
run
command interruptible by adding a couple of sleep statements, so that when hitting CTRL+C sbt had the chance to interrupt the thread.To fix #10864 Greg now switched from
FileDescriptor.in
toSystem.in
in #10890, which totally make sense, however it isn't that easy. Starting with sbt 1.4System.in
is non-blocking, therefore the patch introduced in #9420 makes the sbt console hang when waiting for an input. The problem is thatread()
recursively calls itself in the same thread that is supposed to read data from System.in, but because of the endless loop it never has the chance to do so.Anyway, this comment confirms exactly what I debugged:
To solve this we create the exact same (legacy)
ConsoleReader
when using sbt <=1.3, that already was used before Greg's patch, and yes it still usesFileDescriptor.in
, but that does not matter because until sbt 1.4.x that was totally ok, because there was not client mode yet.For sbt 1.4+ we now create a blocking
ConsoleReader
which just wrapsSystem.in
/System.out
, basically the solution Greg referred to in his pull request.