Buggy code:
public class DataSourceFactory { private static final Localizer _loc = Localizer . forPackage ( DataSourceFactory . class ) ; protected static Localizer _eloc = Localizer . forPackage ( DelegatingDataSource . class ) ; public static DataSource newDataSource ( JDBCConfiguration conf , boolean factory2 ) { } public static DecoratingDataSource decorateDataSource ( DataSource ds , JDBCConfiguration conf , boolean factory2 ) { } public static DecoratingDataSource installDBDictionary ( DBDictionary dict , DecoratingDataSource ds , final JDBCConfiguration conf , boolean factory2 ) { DataSource inner = ds . getInnermostDelegate ( ) ; if ( inner instanceof DriverDataSource ) ( ( DriverDataSource ) ( inner ) ) . initDBDictionary ( dict ) ; Connection conn = null ; try { ConnectionDecorator cd ; for ( Iterator itr = ds . getDecorators ( ) . iterator ( ) ; itr . hasNext ( ) ; ) { cd = ( ( ConnectionDecorator ) ( itr . next ( ) ) ) ; if ( cd instanceof LoggingConnectionDecorator ) ( ( LoggingConnectionDecorator ) ( cd ) ) . setWarningHandler ( dict ) ; } ConfiguringConnectionDecorator ccd = new ConfiguringConnectionDecorator ( ) ; ccd . setTransactionIsolation ( conf . getTransactionIsolationConstant ( ) ) ; <START_BUG> ccd . setQueryTimeout ( ( ( conf . getQueryTimeout ( ) ) == ( - 1 ) ? - 1 : ( conf . getQueryTimeout ( ) ) * 1000 ) ) ; <END_BUG> Log log = conf . getLog ( LOG_JDBC ) ; if ( factory2 || ( ! ( conf . isConnectionFactoryModeManaged ( ) ) ) ) { if ( ! ( dict . supportsMultipleNontransactionalResultSets ) ) ccd . setAutoCommit ( Boolean . FALSE ) ; else ccd . setAutoCommit ( Boolean . TRUE ) ; if ( log . isTraceEnabled ( ) ) log . trace ( DataSourceFactory . _loc . get ( "set-auto-commit" , new Object [ ] { dict . supportsMultipleNontransactionalResultSets } ) ) ; } Options opts = Configurations . parseProperties ( ( factory2 ? conf . getConnectionFactory2Properties ( ) : conf . getConnectionFactoryProperties ( ) ) ) ; Configurations . configureInstance ( ccd , conf , opts ) ; ds . addDecorator ( ccd ) ; ds . addDecorator ( dict ) ; if ( ! factory2 ) conn = ds . getConnection ( conf . getConnectionUserName ( ) , conf . getConnectionPassword ( ) ) ; else conn = ds . getConnection ( conf . getConnection2UserName ( ) , conf . getConnection2Password ( ) ) ; return ds ; } catch ( Exception e ) { throw DataSourceFactory . newConnectException ( conf , factory2 , e ) ; } finally { if ( conn != null ) try { conn . close ( ) ; } catch ( SQLException se ) { } } } static OpenJPAException newConnectException ( JDBCConfiguration conf , boolean factory2 , Exception cause ) { } public static DataSource defaultsDataSource ( DataSource ds , String user , String pass ) { } public static void closeDataSource ( DataSource ds ) { } protected abstract static class DefaultsDataSource extends DelegatingDataSource { private static final Constructor < DataSourceFactory . DefaultsDataSource > implClass ; private final String _user ; private final String _pass ; public DefaultsDataSource ( DataSource ds , String user , String pass ) { } public static DataSourceFactory . DefaultsDataSource newInstance ( DataSource ds , String user , String pass ) { } public Connection getConnection ( ) throws SQLException { } public Connection getConnection ( String user , String pass ) throws SQLException { } } }

Fix:
ccd . setQueryTimeout ( ( ( conf . getQueryTimeout ( ) ) == ( - 1 ) ? - 1 : conf . getQueryTimeout ( ) ) ) ;