@@ -91,10 +91,11 @@ private void normalizeBackupOfferingsIfNeeded(Connection conn) {
9191 String uuid ;
9292 try (PreparedStatement pstmt = conn .prepareStatement (SELECT_NATIVE_OFFERING )) {
9393 ResultSet result = pstmt .executeQuery ();
94- if (!result .next ()) {
95- result = createStandardOffering (conn );
94+ if (result .next ()) {
95+ uuid = result .getString ("uuid" );
96+ } else {
97+ uuid = createStandardOffering (conn );
9698 }
97- uuid = result .getString ("uuid" );
9899 } catch (SQLException e ) {
99100 String message = String .format ("Unable to retrieve Standard native backup offering due to [%s]." , e .getMessage ());
100101 logger .error (message , e );
@@ -122,7 +123,7 @@ private void normalizeBackupOfferingsIfNeeded(Connection conn) {
122123 }
123124 }
124125
125- private ResultSet createStandardOffering (Connection conn ) {
126+ private String createStandardOffering (Connection conn ) {
126127 logger .warn ("Found backup offerings that are inconsistent, but the Standard native backup offering does not exist. Will create it again." );
127128 try (PreparedStatement pstmt = conn .prepareStatement (INSERT_OFFERING )) {
128129 pstmt .executeUpdate ();
@@ -139,7 +140,7 @@ private ResultSet createStandardOffering(Connection conn) {
139140 logger .error (message );
140141 throw new CloudRuntimeException (message );
141142 }
142- return resultSet ;
143+ return resultSet . getString ( "uuid" ) ;
143144 } catch (SQLException e ) {
144145 String message = String .format ("Unable to retrieve native backup offering due to [%s]." , e .getMessage ());
145146 logger .error (message , e );
0 commit comments