Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 9, 2025

Command line execution blocks indefinitely when using System.in due to StreamFeeder performing blocking read() operations. This applies the same fix as maven-shared-utils MSHARED-1072.

Changes

  • New StreamPollFeeder class: Polls InputStream.available() before reading, with 100ms wait intervals when no data is available
  • CommandLineUtils updated: Uses StreamPollFeeder instead of StreamFeeder for feeding system input to process output streams
  • StreamFeeder deprecated: Kept for backward compatibility with clear migration path

Technical approach

The blocking behavior occurs because StreamFeeder.read() waits indefinitely for input:

// Old: blocks forever on System.in
int data = input.read();

New approach polls for available data:

// New: non-blocking poll with timeout
if (input.available() > 0) {
    int i = input.read(buf);
    output.write(buf, 0, i);
    output.flush();
} else {
    lock.wait(100);  // Poll every 100ms
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Poll data from input stream</issue_title>
<issue_description>In order to fix blocking command line execution with leveraging system input stream the same fix applied to https://github.com/apache/maven-shared-utils/pull/140/files (https://issues.apache.org/jira/browse/MSHARED-1072) should be done for plexus-utils as well.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 9, 2025 12:22
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix blocking command line execution in plexus-utils Fix blocking reads from System.in in command line execution Nov 9, 2025
Copilot AI requested a review from slachiewicz November 9, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poll data from input stream

1 participant