This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new 062b98a51ec fix: clean magic value, and update if-else to switch
(#8848)
062b98a51ec is described below
commit 062b98a51eca7da6b6083cbb31c2fb0608448386
Author: cheng102e <[email protected]>
AuthorDate: Wed Jan 28 12:45:11 2026 +0800
fix: clean magic value, and update if-else to switch (#8848)
* fix: clean magic value, and update if-else to switch
* fix: return the (String args[])
* review
---------
Co-authored-by: jiejc1 <[email protected]>
Co-authored-by: Suresh Kumar Anaparti <[email protected]>
---
.../rdpconsole/src/main/java/common/Client.java | 34 +++++++++++++---------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/services/console-proxy/rdpconsole/src/main/java/common/Client.java
b/services/console-proxy/rdpconsole/src/main/java/common/Client.java
index 742f5c9f0cd..972d5d753e8 100644
--- a/services/console-proxy/rdpconsole/src/main/java/common/Client.java
+++ b/services/console-proxy/rdpconsole/src/main/java/common/Client.java
@@ -210,7 +210,6 @@ public class Client {
public void runClient(String[] args) {
try {
-
Protocol protocol = parseOptions(args);
if (protocol == Protocol.NONE)
return;
@@ -299,21 +298,28 @@ public class Client {
private Protocol parseOptions(String[] args) {
String protocolName = (args.length > 0) ? args[0] : "";
- Protocol protocol = Protocol.NONE;
+ Protocol protocol;
Option[] options;
- if (protocolName.equals("vnc")) {
- protocol = Protocol.VNC;
- options = join(commonOptions, vncOptions);
- } else if (protocolName.equals("rdp")) {
- protocol = Protocol.RDP;
- options = join(commonOptions, rdpOptions);
- } else if (protocolName.equals("hyperv")) {
- protocol = Protocol.HYPERV;
- options = join(commonOptions, hyperVOptions);
- } else {
- help();
- return Protocol.NONE;
+ try {
+ protocol = Protocol.valueOf(protocolName);
+ } catch (IllegalArgumentException e) {
+ protocol = Protocol.NONE;
+ }
+
+ switch (protocol) {
+ case VNC:
+ options = join(commonOptions, vncOptions);
+ break;
+ case RDP:
+ options = join(commonOptions, rdpOptions);
+ break;
+ case HYPERV:
+ options = join(commonOptions, hyperVOptions);
+ break;
+ default:
+ help();
+ return Protocol.NONE;
}
// Parse all options for given protocol