File tree Expand file tree Collapse file tree
framework/config/src/org/apache/cloudstack/framework/config/dao Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,44 +144,28 @@ public void init() throws ConfigurationException {
144144 @ Deprecated
145145 public boolean update (String name , String value ) {
146146 TransactionLegacy txn = TransactionLegacy .currentTxn ();
147- PreparedStatement stmt = null ;
148- try {
149- stmt = txn .prepareStatement (UPDATE_CONFIGURATION_SQL );
147+ try (PreparedStatement stmt = txn .prepareStatement (UPDATE_CONFIGURATION_SQL );){
150148 stmt .setString (1 , value );
151149 stmt .setString (2 , name );
152150 stmt .executeUpdate ();
153151 return true ;
154152 } catch (Exception e ) {
155153 s_logger .warn ("Unable to update Configuration Value" , e );
156- } finally {
157- try {
158- if (stmt != null )
159- stmt .close ();
160- } catch (SQLException e ) {
161- }
162154 }
163155 return false ;
164156 }
165157
166158 @ Override
167159 public boolean update (String name , String category , String value ) {
168160 TransactionLegacy txn = TransactionLegacy .currentTxn ();
169- PreparedStatement stmt = null ;
170- try {
171- value = ("Hidden" .equals (category ) || "Secure" .equals (category )) ? DBEncryptionUtil .encrypt (value ) : value ;
172- stmt = txn .prepareStatement (UPDATE_CONFIGURATION_SQL );
161+ value = ("Hidden" .equals (category ) || "Secure" .equals (category )) ? DBEncryptionUtil .encrypt (value ) : value ;
162+ try (PreparedStatement stmt = txn .prepareStatement (UPDATE_CONFIGURATION_SQL );) {
173163 stmt .setString (1 , value );
174164 stmt .setString (2 , name );
175165 stmt .executeUpdate ();
176166 return true ;
177167 } catch (Exception e ) {
178168 s_logger .warn ("Unable to update Configuration Value" , e );
179- } finally {
180- try {
181- if (stmt != null )
182- stmt .close ();
183- } catch (SQLException e ) {
184- }
185169 }
186170 return false ;
187171 }
You can’t perform that action at this time.
0 commit comments