Bug 12286

Summary: NullPointerException in JDBCStore (fix included)
Product: Tomcat 4 Reporter: Ronald Klop <ronald>
Component: Catalina:ModulesAssignee: Tomcat Developers Mailing List <dev>
Status: CLOSED FIXED    
Severity: major Keywords: PatchAvailable
Priority: P3    
Version: 4.1.10   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Ronald Klop 2002-09-04 08:29:00 UTC
I get a NullPointerException in the cleanup code of org.apache.catalina.session.JDBCStore 
using Tomcat 4.0.4.
This happens while reloading the context.
After the exception tomcat 
hangs until you reload the context again.

I think it can be solved with the following 
'patch'.

--- org/apache/catalina/session/JDBCStore-old.java  Wed Sep  4 02:13:53 2002
+++ 
org/apache/catalina/session/JDBCStore.java      Wed Sep  4 02:18:12 2002
@@ -759,37 +759,43 @@
             
}

             try {
-                preparedSizeSql.close();
+                if (preparedSizeSql != null)
+                    
preparedSizeSql.close();
             } catch (SQLException e) {
                 ;
             }

             try {
-                
preparedKeysSql.close();
+                if (preparedKeysSql != null)
+                    preparedKeysSql.close();
             } 
catch (SQLException e) {
                 ;
             }

             try {
-                preparedSaveSql.close();
+                if (preparedSaveSql 
!= null)
+                    preparedSaveSql.close();
             } catch (SQLException e) {
                 ;
             }

             try {
-                
preparedClearSql.close();
+                if (preparedClearSql != null)
+                    
preparedClearSql.close();
             } catch (SQLException e) {
                 ;
             }

             try {
-                
preparedRemoveSql.close();
+                if (preparedRemoveSql != null)
+                    
preparedRemoveSql.close();
             } catch (SQLException e) {
                 ;
             }

             try {
-                
preparedLoadSql.close();
+                if (preparedLoadSql != null)
+                    preparedLoadSql.close();
             } 
catch (SQLException e) {
                 ;
             }
Comment 1 Ronald Klop 2002-09-20 11:22:59 UTC
I've seen this bug in 4.0.4 and also in 4.1.10.
It's a trivial fix. Can it be included in 4.1.11?
Comment 2 Glenn Nielsen 2002-09-20 14:07:47 UTC
I have committed a patch for this to CVS. Tomcat 4.1.11 has already been
released but this bug fix will be available in the next nightly build.
Or you can wait for the Tomcat 4.1.12 release.