connectivity/source/cpool/ZConnectionPool.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7e989259c63946b17cc0c7b765e4fa8261a06507
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Aug 11 11:04:14 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Aug 11 18:07:39 2022 +0200

    connectivity: avoid divide by zero in calculateTimeOuts
    
    See 
https://crashreport.libreoffice.org/stats/signature/connectivity::OConnectionPool::propertyChange(com::sun::star::beans::PropertyChangeEvent%20const%20&)
    
    To reproduce this, blow away your config and start writer, visit tools,
    options, base, connections and enable connection pooling enabled, find
    com.sun.star.sdbcx.comp.hdqldb.Driver and "enable pooling for this
    driver" and "apply" with the default 120 seconds, ok and exit
    
    then open a database (based on hsqldb) and click on "tables" (to start a
    connection) that default 120 seconds is the input for calculateTimeOuts
    (this becomes a final m_nALiveCount of 10 by the divide by 20), now
    visit the options again and change the 120 to something else and ok and
    the input for calculateTimeOuts is the old "10" calculated before and
    not the new expected value.
    
    The reason appears to be in OConnectionPool::propertyChange, it expects
    to get the new value of the property from evt.NewValue but it gets an
    empty Any so the m_nALiveCount is not actually changed, so the
    assumption it was set and will be >= 20 and sanely divisible by 20
    doesn't hold.
    
    For this easy fix, fetch the new value explicitly from the config
    
    Change-Id: Ie91bf5328634f9aafbda1814b10c29b86a3f9cbe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138111
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/connectivity/source/cpool/ZConnectionPool.cxx 
b/connectivity/source/cpool/ZConnectionPool.cxx
index cc90fa464e16..23e6dda1d226 100644
--- a/connectivity/source/cpool/ZConnectionPool.cxx
+++ b/connectivity/source/cpool/ZConnectionPool.cxx
@@ -282,7 +282,7 @@ void SAL_CALL OConnectionPool::propertyChange( const 
PropertyChangeEvent& evt )
 {
     if(TIMEOUT_NODENAME == evt.PropertyName)
     {
-        evt.NewValue >>= m_nALiveCount;
+        OPoolCollection::getNodeValue(TIMEOUT_NODENAME, m_xDriverNode) >>= 
m_nALiveCount;
         calculateTimeOuts();
     }
 }

Reply via email to