summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-01-29 11:11:18 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-01-29 11:11:18 -0800
commitd3485542a172e9625c1ce0460b2e7f4f89105318 (patch)
tree29b77cdb6bb4c5c1f6bb95677868e3e473fc3e4b
parent9e935923649cdf29156c854c6630dd9e7d2b2cf0 (diff)
parenta9de3aa8e71373f6ec2d312b0662ded7664bee07 (diff)
Merge "Flush output buffers when command is complete" into main
-rw-r--r--core/java/com/android/internal/os/BaseCommand.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/java/com/android/internal/os/BaseCommand.java b/core/java/com/android/internal/os/BaseCommand.java
index c85b5d7aa7a6..af763e4c5fa9 100644
--- a/core/java/com/android/internal/os/BaseCommand.java
+++ b/core/java/com/android/internal/os/BaseCommand.java
@@ -58,15 +58,23 @@ public abstract class BaseCommand {
mRawArgs = args;
mArgs.init(null, null, null, null, args, 0);
+ int status = 1;
try {
onRun();
+ status = 0;
} catch (IllegalArgumentException e) {
onShowUsage(System.err);
System.err.println();
System.err.println("Error: " + e.getMessage());
+ status = 0;
} catch (Exception e) {
e.printStackTrace(System.err);
- System.exit(1);
+ } finally {
+ System.out.flush();
+ System.err.flush();
+ }
+ if (status != 0) {
+ System.exit(status);
}
}