mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
safely close resource with java 1.7 resource block
Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
This commit is contained in:
parent
5e4fec9eca
commit
3e3ded75f4
@ -3324,13 +3324,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
|
||||
if (pubKeyFile.exists()) {
|
||||
String pubKey = cmd.getPubKey();
|
||||
try {
|
||||
FileOutputStream pubkStream = new FileOutputStream(pubKeyFile);
|
||||
pubkStream.write(pubKey.getBytes());
|
||||
pubkStream.close();
|
||||
try (FileOutputStream pubkStream = new FileOutputStream(pubKeyFile)) {
|
||||
pubkStream.write(cmd.getPubKey().getBytes());
|
||||
} catch (FileNotFoundException e) {
|
||||
result = "File" + SSHPUBKEYPATH + "is not found:" + e.toString();
|
||||
result = "File" + SSHPUBKEYPATH + "is not found:"
|
||||
+ e.toString();
|
||||
s_logger.debug(result);
|
||||
} catch (IOException e) {
|
||||
result = "Write file " + SSHPUBKEYPATH + ":" + e.toString();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user