Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-39

[PATCH] SharedPoolDataSource - close() method closes pool instance only when pool available (initialized)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 37359

    Description

      When SharedPoolDataSource is created and never initialized by call to
      registerPool(String, String) method (called by getPooledConnectionAndInfo()
      method , so no connection is requested from any caller), and the method close()
      is called, the NullPointerException raises like this:
      2005-11-04 16:24:15,990 [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
      ERROR org.apache.torque.dsfactory.SharedPoolDataSourceFactory - Exception caught
      during close()
      java.lang.NullPointerException
      at
      org.apache.commons.dbcp.datasources.SharedPoolDataSource.close(SharedPoolDataSource.java:64)
      at
      org.apache.torque.dsfactory.SharedPoolDataSourceFactory.close(SharedPoolDataSourceFactory.java:111)
      at org.apache.torque.TorqueInstance.shutdown(TorqueInstance.java:575)
      at org.apache.torque.avalon.TorqueComponent.stop(TorqueComponent.java:188)
      at
      org.apache.avalon.framework.container.ContainerUtil.stop(ContainerUtil.java:314)
      at
      org.apache.avalon.excalibur.component.DefaultComponentFactory.decommission(DefaultComponentFactory.java:381)
      at
      org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.dispose(ThreadSafeComponentHandler.java:198)
      at
      org.apache.avalon.excalibur.component.ExcaliburComponentManager.dispose(ExcaliburComponentManager.java:654)
      at
      org.apache.turbine.services.avaloncomponent.TurbineAvalonComponentService.dispose(TurbineAvalonComponentService.java:204)
      at
      org.apache.turbine.services.avaloncomponent.TurbineAvalonComponentService.shutdown(TurbineAvalonComponentService.java:115)
      at
      org.apache.turbine.services.BaseServiceBroker.shutdownService(BaseServiceBroker.java:383)
      at
      org.apache.turbine.services.BaseServiceBroker.shutdownServices(BaseServiceBroker.java:429)
      at org.apache.turbine.Turbine.destroy(Turbine.java:628)
      PooledConnection

      (output from logs of apache turbine, when the turbine application is deployed to
      tomcat and then re-deployed ).

      To fix this, there is a patch:

      getPooledConnectionvimr@bene2:/var/data/src/java/commons-dbcp-cvs/jakarta-commons>
      cvs diff -u
      dbcp/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
      Index: dbcp/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
      ===================================================================
      RCS file:
      /home/cvspublic/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java,v
      retrieving revision 1.10
      diff -u -r1.10 SharedPoolDataSource.java
      — dbcp/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
      20 Oct 2004 20:46:30 -0000 1.10
      +++ dbcp/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
      4 Nov 2005 15:37:24 -0000
      @@ -61,7 +61,10 @@

      • Close pool being maintained by this datasource.
        */
        public void close() throws Exception { - pool.close(); + + if(pool != null) + pool.close(); + InstanceKeyObjectFactory.removeInstance(instanceKey); }

      Jindrich Vimr
      <vimr@hsf.cz>

      Attachments

        Activity

          People

            Unassigned Unassigned
            vimr@hsf.cz Jindrich Vimr
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: