Skip to content
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

BlockingProcessStreamReader.java doesn't log the error text and silently exits #9097

Closed
jainsahab opened this issue Nov 22, 2022 · 1 comment · Fixed by #9108
Closed

BlockingProcessStreamReader.java doesn't log the error text and silently exits #9097

jainsahab opened this issue Nov 22, 2022 · 1 comment · Fixed by #9108
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@jainsahab
Copy link
Contributor

jainsahab commented Nov 22, 2022

BlockingProcessStreamReader.java is a separate thread which checks for blockUntil text to appear in it's constructor.
https://github.com/googleapis/java-core/blob/main/google-cloud-core/src/main/java/com/google/cloud/testing/BlockingProcessStreamReader.java#L47-L61

In cases where process is abruptly closed and resulted in non zero exit code, BlockingProcessStreamReader.java doesn't log the startup logs(which may contain the error information). This causes confusion to the end user.

Steps to reproduce

  • Run gcloud beta emulators datastore startss (notice the typo in command) to check the error text we get on stdout.
➜  java-core git:(gh_issue_1038) ✗ gcloud beta emulators datastore startss
ERROR: (gcloud.beta.emulators.datastore) Invalid choice: 'startss'.
Maybe you meant:
  gcloud beta emulators datastore start
  gcloud beta emulators datastore env-init
  gcloud beta emulators datastore env-unset
  gcloud beta emulators bigtable start
  gcloud beta emulators firestore start
  gcloud beta emulators pubsub start

To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS
  • Execute below code and we can see that nothing is logged now.
import java.io.IOException;
import java.util.Arrays;
import java.util.logging.Logger;

public class Playground {

  public static void main(String[] args) throws IOException, InterruptedException {

    Process process = CommandWrapper.create()
        .setCommand(Arrays.asList("gcloud beta emulators datastore startss".split(" "))) // notice the typo in command
        .setRedirectErrorStream().start();
    BlockingProcessStreamReader blockingProcessStreamReader = BlockingProcessStreamReader.start(
        "test-playground", process.getInputStream(), "blockUntilOutput",
        Logger.getLogger(Playground.class.getName()));

    blockingProcessStreamReader.join();

    System.out.printf("Subprocess exit code: %d%n", process.exitValue()); // should print non zero value
  }

}

Ref: Similar issue happened in googleapis/java-datastore#355.

@diegomarquezp diegomarquezp added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 12, 2022
@suztomo suztomo transferred this issue from googleapis/java-core Feb 8, 2023
@jainsahab
Copy link
Contributor Author

Hi @suztomo regarding googleapis/java-core#1039 (comment), #9108 is raised. let me know if you see any problem while reviewing this.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
2 participants