mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8656: try-with resource on socket channel
This commit is contained in:
parent
ea886910d8
commit
55df06779b
|
|
@ -2363,10 +2363,8 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
// VM patching/rebooting time that may need
|
||||
int retry = _retry;
|
||||
while (System.currentTimeMillis() - startTick <= _opsTimeout || --retry > 0) {
|
||||
SocketChannel sch = null;
|
||||
try {
|
||||
s_logger.info("Trying to connect to " + ipAddress);
|
||||
sch = SocketChannel.open();
|
||||
s_logger.info("Trying to connect to " + ipAddress);
|
||||
try (SocketChannel sch = SocketChannel.open();) {
|
||||
sch.configureBlocking(true);
|
||||
sch.socket().setSoTimeout(5000);
|
||||
// we need to connect to the control ip address to check the status of the system vm
|
||||
|
|
@ -2385,13 +2383,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
s_logger.debug("[ignored] interupted while waiting to retry connecting to vm after exception: "+e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (sch != null) {
|
||||
try {
|
||||
sch.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue