From 7e5b7e5f39500df7bf521e37e88dda5732d3234f Mon Sep 17 00:00:00 2001 From: Joshua Dowell Date: Fri, 13 Mar 2026 10:48:52 -0500 Subject: [PATCH] fix: exit cleanly on failed login in oiecommand (#224) UnauthorizedException was caught by the generic ClientException handler which only printed a stack trace and returned, leaving Jersey HTTP client threads running and the process hanging indefinitely. Catch UnauthorizedException before ClientException, print a clear "invalid username or password" message, and call System.exit(1) so the process terminates. Also exit on other ClientExceptions rather than swallowing them silently. Fixes #224 Co-Authored-By: Claude Sonnet 4.6 --- .../src/com/mirth/connect/cli/CommandLineInterface.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/command/src/com/mirth/connect/cli/CommandLineInterface.java b/command/src/com/mirth/connect/cli/CommandLineInterface.java index 3f757d4ca..ca9ca2f94 100644 --- a/command/src/com/mirth/connect/cli/CommandLineInterface.java +++ b/command/src/com/mirth/connect/cli/CommandLineInterface.java @@ -56,6 +56,7 @@ import com.mirth.connect.client.core.BrandingConstants; import com.mirth.connect.client.core.Client; import com.mirth.connect.client.core.ClientException; +import com.mirth.connect.client.core.UnauthorizedException; import com.mirth.connect.client.core.ListHandlerException; import com.mirth.connect.client.core.PaginatedEventList; import com.mirth.connect.client.core.PaginatedMessageList; @@ -218,8 +219,12 @@ private void runShell(String server, String user, String password, String script client.logout(); client.close(); out.println("Disconnected from server."); + } catch (UnauthorizedException ue) { + error("Could not login to server: invalid username or password.", null); + System.exit(1); } catch (ClientException ce) { - ce.printStackTrace(); + error("A client error occurred.", ce); + System.exit(1); } catch (IOException ioe) { error("Could not load script file.", ioe); } catch (URISyntaxException e) {