Buggy code:
public class Upgrade421to430 implements DbUpgrade { static final Logger s_logger = Logger . getLogger ( Upgrade421to430 . class ) ; @ Override public String [ ] getUpgradableVersionRange ( ) { } @ Override public String getUpgradedVersion ( ) { } @ Override public boolean supportsRollingUpgrade ( ) { } @ Override public File [ ] getPrepareScripts ( ) { } @ Override public void performDataMigration ( Connection conn ) { } private void upgradeMemoryOfSsvmOffering ( Connection conn ) { } private void encryptLdapConfigParams ( Connection conn ) { PreparedStatement pstmt = null ; String [ ] [ ] ldapParams = new String [ ] [ ] { new String [ ] { "ldap.user.object" , "inetOrgPerson" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>object<seq2seq4repair_space>type<seq2seq4repair_space>of<seq2seq4repair_space>users<seq2seq4repair_space>within<seq2seq4repair_space>LDAP" } , new String [ ] { "ldap.username.attribute" , "uid" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>username<seq2seq4repair_space>attribute<seq2seq4repair_space>used<seq2seq4repair_space>within<seq2seq4repair_space>LDAP" } , new String [ ] { "ldap.email.attribute" , "mail" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>email<seq2seq4repair_space>attribute<seq2seq4repair_space>used<seq2seq4repair_space>within<seq2seq4repair_space>LDAP" } , new String [ ] { "ldap.firstname.attribute" , "givenname" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>firstname<seq2seq4repair_space>attribute<seq2seq4repair_space>used<seq2seq4repair_space>within<seq2seq4repair_space>LDAP" } , new String [ ] { "ldap.lastname.attribute" , "sn" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>lastname<seq2seq4repair_space>attribute<seq2seq4repair_space>used<seq2seq4repair_space>within<seq2seq4repair_space>LDAP" } , new String [ ] { "ldap.group.object" , "groupOfUniqueNames" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>object<seq2seq4repair_space>type<seq2seq4repair_space>of<seq2seq4repair_space>groups<seq2seq4repair_space>within<seq2seq4repair_space>LDAP" } , new String [ ] { "ldap.group.user.uniquemember" , "uniquemember" , "Sets<seq2seq4repair_space>the<seq2seq4repair_space>attribute<seq2seq4repair_space>for<seq2seq4repair_space>uniquemembers<seq2seq4repair_space>within<seq2seq4repair_space>a<seq2seq4repair_space>group" } } ; String insertSql = "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>`cloud`.`configuration`(category,<seq2seq4repair_space>instance,<seq2seq4repair_space>component,<seq2seq4repair_space>name,<seq2seq4repair_space>value,<seq2seq4repair_space>description)<seq2seq4repair_space>VALUES<seq2seq4repair_space>('Secure',<seq2seq4repair_space>'DEFAULT',<seq2seq4repair_space>'management-server',<seq2seq4repair_space>?,<seq2seq4repair_space>?,<seq2seq4repair_space>" + "?)<seq2seq4repair_space>ON<seq2seq4repair_space>DUPLICATE<seq2seq4repair_space>KEY<seq2seq4repair_space>UPDATE<seq2seq4repair_space>category='Secure';" ; try { pstmt = conn . prepareStatement ( insertSql ) ; for ( String [ ] ldapParam : ldapParams ) { String name = ldapParam [ 0 ] ; String value = ldapParam [ 1 ] ; String desc = ldapParam [ 2 ] ; String encryptedValue = DBEncryptionUtil . encrypt ( value ) ; pstmt . setString ( 1 , name ) ; pstmt . setBytes ( 2 , encryptedValue . getBytes ( "UTF-8" ) ) ; pstmt . setString ( 3 , desc ) ; pstmt . executeUpdate ( ) ; } pstmt . close ( ) ; pstmt = conn . prepareStatement ( "SELECT<seq2seq4repair_space>conf.value<seq2seq4repair_space>FROM<seq2seq4repair_space>`cloud`.`configuration`<seq2seq4repair_space>conf<seq2seq4repair_space>WHERE<seq2seq4repair_space>conf.name='ldap.hostname'" ) ; ResultSet resultSet = pstmt . executeQuery ( ) ; String hostname = null ; String port ; int portNumber = 0 ; if ( resultSet . next ( ) ) { hostname = DBEncryptionUtil . decrypt ( resultSet . getString ( 1 ) ) ; } pstmt . close ( ) ; pstmt = conn . prepareStatement ( "SELECT<seq2seq4repair_space>conf.value<seq2seq4repair_space>FROM<seq2seq4repair_space>`cloud`.`configuration`<seq2seq4repair_space>conf<seq2seq4repair_space>WHERE<seq2seq4repair_space>conf.name='ldap.port'" ) ; resultSet = pstmt . executeQuery ( ) ; if ( resultSet . next ( ) ) { port = DBEncryptionUtil . decrypt ( resultSet . getString ( 1 ) ) ; if ( StringUtils . isNotBlank ( port ) ) { <START_BUG> portNumber = Integer . valueOf ( port ) ; <END_BUG> } } pstmt . close ( ) ; if ( StringUtils . isNotBlank ( hostname ) ) { pstmt = conn . prepareStatement ( "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>`cloud`.`ldap_configuration`(hostname,<seq2seq4repair_space>port)<seq2seq4repair_space>VALUES(?,?)" ) ; pstmt . setString ( 1 , hostname ) ; if ( portNumber != 0 ) { pstmt . setInt ( 2 , portNumber ) ; } else { pstmt . setNull ( 2 , Types . INTEGER ) ; } pstmt . executeUpdate ( ) ; pstmt . close ( ) ; } } catch ( SQLException e ) { throw new CloudRuntimeException ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>insert<seq2seq4repair_space>ldap<seq2seq4repair_space>configuration<seq2seq4repair_space>values<seq2seq4repair_space>" , e ) ; } catch ( UnsupportedEncodingException e ) { throw new CloudRuntimeException ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>insert<seq2seq4repair_space>ldap<seq2seq4repair_space>configuration<seq2seq4repair_space>values<seq2seq4repair_space>" , e ) ; } finally { try { if ( pstmt != null ) { pstmt . close ( ) ; } } catch ( SQLException e ) { } } Upgrade421to430 . s_logger . debug ( "Done<seq2seq4repair_space>encrypting<seq2seq4repair_space>ldap<seq2seq4repair_space>Config<seq2seq4repair_space>values" ) ; } private void encryptImageStoreDetails ( Connection conn ) { } @ Override public File [ ] getCleanupScripts ( ) { } }

Fix:
portNumber = Integer . parseInt ( port ) ;