Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions command/src/com/mirth/connect/cli/CommandLineInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -216,14 +217,19 @@ private void runShell(String server, String user, String password, String script
runConsole();
}
client.logout();
client.close();
out.println("Disconnected from server.");
} catch (UnauthorizedException ue) {
error("Could not login to server: invalid username or password.", null);
} catch (ClientException ce) {
ce.printStackTrace();
error("A client error occurred.", ce);
} catch (IOException ioe) {
error("Could not load script file.", ioe);
} catch (URISyntaxException e) {
error("Invalid server address.", e);
} finally {
if (client != null) {
client.close();
}
Comment on lines +229 to +232

@kpalang kpalang Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Since Client implements AutoCloseable I would replace the finally clock with a try-with-resources approach.

try (var client = new Client(server)) {

}
}

Expand Down