SapiensAnatis opened a new pull request, #1648: URL: https://github.com/apache/maven-mvnd/pull/1648
Closes #1452. This PR addresses two issues with standard input handling, when invoking `mvnd` in a dumb terminal with piped input, for example: ``` echo "Hello world" | mvnd somegoal ``` The motivating scenario for this is to use Spotless with mvnd, which includes an IDE integration that uses stdin to pipe a document to be formatted and sent back on stdout instead of providing a path and relying on slower filesystem reads/writes: https://github.com/diffplug/spotless/blob/main/plugin-maven/IDE_HOOK.md The issues are: 1. `DaemonInputStream.available()` often misleadingly reports 0 or 1, and in general can only report bytes that have already been pre-read into a buffer by the daemon - This PR addresses this by introducing 2 new message types: one that asks clients to call `System.in.available()` and one that contains the result of this operation. 3. If `TerminalInputHandler` is able to read to the end of stdin (as it will in a pipe scenario) it sends an EOF message _and then_ the data message. This leads to the data being ignored by `DaemonInputStream` as it sets the `eof` field to true, which causes a return from `read` with 0 bytes. - This PR re-arranges the order in which these messages are sent to ensure data is sent before an EOF. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
