mirror of https://github.com/apache/cloudstack.git
fix bug 7180
This commit is contained in:
parent
5329a19c66
commit
42ee65fce3
|
|
@ -157,14 +157,24 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
if(rs != null && rs.next()) {
|
||||
returnValue = rs.getString(1);
|
||||
} else {
|
||||
stmtInsert = txn.prepareAutoCloseStatement("INSERT INTO configuration(instance, name, value, description) VALUES('DEFAULT', ?, ?, '')");
|
||||
stmtInsert.setString(1, name);
|
||||
stmtInsert.setString(2, initValue);
|
||||
if(stmtInsert.executeUpdate() < 1) {
|
||||
throw new CloudRuntimeException("Unable to init configuration variable: " + name);
|
||||
if(returnValue != null) {
|
||||
txn.commit();
|
||||
return returnValue;
|
||||
} else {
|
||||
// restore init value
|
||||
returnValue = initValue;
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
|
||||
stmtInsert = txn.prepareAutoCloseStatement(
|
||||
"INSERT INTO configuration(instance, name, value, description) VALUES('DEFAULT', ?, ?, '') ON DUPLICATE KEY UPDATE value=?");
|
||||
stmtInsert.setString(1, name);
|
||||
stmtInsert.setString(2, initValue);
|
||||
stmtInsert.setString(3, initValue);
|
||||
if(stmtInsert.executeUpdate() < 1) {
|
||||
throw new CloudRuntimeException("Unable to init configuration variable: " + name);
|
||||
}
|
||||
txn.commit();
|
||||
return returnValue;
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue