DaanHoogland commented on code in PR #8848:
URL: https://github.com/apache/cloudstack/pull/8848#discussion_r2731333782
##########
services/console-proxy/rdpconsole/src/main/java/common/Client.java:
##########
@@ -299,21 +303,25 @@ private Element
setMainElementAndAddressBasedOnProtocol(Protocol protocol, SSLSt
private Protocol parseOptions(String[] args) {
String protocolName = (args.length > 0) ? args[0] : "";
- Protocol protocol = Protocol.NONE;
+ Protocol protocol;
Review Comment:
```suggestion
Protocol protocol;
try {
protocol = Protocol.valueOf(protocolname);
} catch (IllegalArgumentException || NullPointerException e) {
protocol = Protocol.None;
}
```
##########
services/console-proxy/rdpconsole/src/main/java/common/Client.java:
##########
@@ -299,21 +303,25 @@ private Element
setMainElementAndAddressBasedOnProtocol(Protocol protocol, SSLSt
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;
+ switch (protocolName) {
+ case VNC:
+ protocol = Protocol.VNC;
+ options = join(commonOptions, vncOptions);
+ break;
+ case RDP:
+ protocol = Protocol.RDP;
+ options = join(commonOptions, rdpOptions);
+ break;
+ case HYPERV:
+ protocol = Protocol.HYPERV;
+ options = join(commonOptions, hyperVOptions);
+ break;
+ default:
+ help();
+ return Protocol.NONE;
}
Review Comment:
```suggestion
switch (protocol) {
case Protocol.VNC:
options = join(commonOptions, vncOptions);
break;
case Protocol.RDP:
options = join(commonOptions, rdpOptions);
break;
case Protocol.HYPERV:
options = join(commonOptions, hyperVOptions);
break;
default:
help();
return Protocol.NONE;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]