Skip to content

Commit e530439

Browse files
Joshua Dowellclaude
andcommitted
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 <noreply@anthropic.com> Signed-off-by: Joshua Dowell <joshua.dowell@centrallogic.com>
1 parent 7723b34 commit e530439

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

command/src/com/mirth/connect/cli/CommandLineInterface.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import com.mirth.connect.client.core.BrandingConstants;
5757
import com.mirth.connect.client.core.Client;
5858
import com.mirth.connect.client.core.ClientException;
59+
import com.mirth.connect.client.core.UnauthorizedException;
5960
import com.mirth.connect.client.core.ListHandlerException;
6061
import com.mirth.connect.client.core.PaginatedEventList;
6162
import com.mirth.connect.client.core.PaginatedMessageList;
@@ -216,14 +217,19 @@ private void runShell(String server, String user, String password, String script
216217
runConsole();
217218
}
218219
client.logout();
219-
client.close();
220220
out.println("Disconnected from server.");
221+
} catch (UnauthorizedException ue) {
222+
error("Could not login to server: invalid username or password.", null);
221223
} catch (ClientException ce) {
222-
ce.printStackTrace();
224+
error("A client error occurred.", ce);
223225
} catch (IOException ioe) {
224226
error("Could not load script file.", ioe);
225227
} catch (URISyntaxException e) {
226228
error("Invalid server address.", e);
229+
} finally {
230+
if (client != null) {
231+
client.close();
232+
}
227233
}
228234
}
229235

0 commit comments

Comments
 (0)