mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed coverity issues reported
This commit is contained in:
parent
1cf1abcf47
commit
b371356abc
@ -441,13 +441,15 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
|||||||
if (propsFile == null) {
|
if (propsFile == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
final FileInputStream finputstream = new FileInputStream(propsFile);
|
|
||||||
final Properties props = new Properties();
|
final Properties props = new Properties();
|
||||||
props.load(finputstream);
|
try(final FileInputStream finputstream = new FileInputStream(propsFile);) {
|
||||||
finputstream.close();
|
props.load(finputstream);
|
||||||
|
}catch (IOException e) {
|
||||||
|
s_logger.error("getEnvironmentProperty:Exception:" + e.getMessage());
|
||||||
|
}
|
||||||
return props.getProperty("mount.parent");
|
return props.getProperty("mount.parent");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -846,10 +848,10 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (keyfile.exists()) {
|
if (keyfile.exists()) {
|
||||||
try {
|
try (FileOutputStream kStream = new FileOutputStream(keyfile);){
|
||||||
FileOutputStream kStream = new FileOutputStream(keyfile);
|
if (kStream != null) {
|
||||||
kStream.write(key.getBytes());
|
kStream.write(key.getBytes());
|
||||||
kStream.close();
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
s_logger.warn("Failed to write key to " + keyfile.getAbsolutePath());
|
s_logger.warn("Failed to write key to " + keyfile.getAbsolutePath());
|
||||||
throw new CloudRuntimeException("Failed to update keypairs on disk: cannot find key file " + keyPath);
|
throw new CloudRuntimeException("Failed to update keypairs on disk: cannot find key file " + keyPath);
|
||||||
|
|||||||
@ -1361,28 +1361,31 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
if (tmpFile == null) {
|
if (tmpFile == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FileReader fr = new FileReader(tmpFile);
|
try (FileReader fr = new FileReader(tmpFile);
|
||||||
BufferedReader brf = new BufferedReader(fr);
|
BufferedReader brf = new BufferedReader(fr);) {
|
||||||
String line = null;
|
String line = null;
|
||||||
String uniqName = null;
|
String uniqName = null;
|
||||||
Long size = null;
|
Long size = null;
|
||||||
String name = null;
|
String name = null;
|
||||||
while ((line = brf.readLine()) != null) {
|
while ((line = brf.readLine()) != null) {
|
||||||
if (line.startsWith("uniquename=")) {
|
if (line.startsWith("uniquename=")) {
|
||||||
uniqName = line.split("=")[1];
|
uniqName = line.split("=")[1];
|
||||||
} else if (line.startsWith("size=")) {
|
} else if (line.startsWith("size=")) {
|
||||||
size = Long.parseLong(line.split("=")[1]);
|
size = Long.parseLong(line.split("=")[1]);
|
||||||
} else if (line.startsWith("filename=")) {
|
} else if (line.startsWith("filename=")) {
|
||||||
name = line.split("=")[1];
|
name = line.split("=")[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
tempFile.delete();
|
||||||
|
if (uniqName != null) {
|
||||||
|
TemplateProp prop = new TemplateProp(uniqName, container + File.separator + name, size, size, true, false);
|
||||||
|
tmpltInfos.put(uniqName, prop);
|
||||||
|
}
|
||||||
|
} catch (IOException ex)
|
||||||
|
{
|
||||||
|
s_logger.debug("swiftListTemplate:Exception:" + ex.getMessage());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
brf.close();
|
|
||||||
tempFile.delete();
|
|
||||||
if (uniqName != null) {
|
|
||||||
TemplateProp prop = new TemplateProp(uniqName, container + File.separator + name, size, size, true, false);
|
|
||||||
tmpltInfos.put(uniqName, prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.debug("Failed to create templ file:" + e.toString());
|
s_logger.debug("Failed to create templ file:" + e.toString());
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user