Author: markt
Date: Sun Feb  7 22:16:40 2010
New Revision: 907502

URL: http://svn.apache.org/viewvc?rev=907502&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48643
Clean up

Modified:
    tomcat/trunk/java/org/apache/catalina/session/FileStore.java
    tomcat/trunk/java/org/apache/catalina/session/StandardManager.java

Modified: tomcat/trunk/java/org/apache/catalina/session/FileStore.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/FileStore.java?rev=907502&r1=907501&r2=907502&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/FileStore.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/FileStore.java Sun Feb  7 
22:16:40 2010
@@ -258,12 +258,13 @@
         }
 
         FileInputStream fis = null;
+        BufferedInputStream bis = null;
         ObjectInputStream ois = null;
         Loader loader = null;
         ClassLoader classLoader = null;
         try {
             fis = new FileInputStream(file.getAbsolutePath());
-            BufferedInputStream bis = new BufferedInputStream(fis);
+            bis = new BufferedInputStream(fis);
             Container container = manager.getContainer();
             if (container != null)
                 loader = container.getLoader();
@@ -278,13 +279,19 @@
                 manager.getContainer().getLogger().debug("No persisted data 
file found");
             return (null);
         } catch (IOException e) {
-            if (ois != null) {
+            if (bis != null) {
                 try {
-                    ois.close();
+                    bis.close();
+                } catch (IOException f) {
+                    // Ignore
+                }
+            }
+            if (fis != null) {
+                try {
+                    fis.close();
                 } catch (IOException f) {
                     // Ignore
                 }
-                ois = null;
             }
             throw e;
         }
@@ -297,12 +304,10 @@
             return (session);
         } finally {
             // Close the input stream
-            if (ois != null) {
-                try {
-                    ois.close();
-                } catch (IOException f) {
-                    // Ignore
-                }
+            try {
+                ois.close();
+            } catch (IOException f) {
+                // Ignore
             }
         }
     }
@@ -357,9 +362,9 @@
             fos = new FileOutputStream(file.getAbsolutePath());
             oos = new ObjectOutputStream(new BufferedOutputStream(fos));
         } catch (IOException e) {
-            if (oos != null) {
+            if (fos != null) {
                 try {
-                    oos.close();
+                    fos.close();
                 } catch (IOException f) {
                     // Ignore
                 }

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardManager.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardManager.java?rev=907502&r1=907501&r2=907502&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardManager.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardManager.java Sun Feb  
7 22:16:40 2010
@@ -355,12 +355,13 @@
         if (log.isDebugEnabled())
             log.debug(sm.getString("standardManager.loading", pathname));
         FileInputStream fis = null;
+        BufferedInputStream bis = null;
         ObjectInputStream ois = null;
         Loader loader = null;
         ClassLoader classLoader = null;
         try {
             fis = new FileInputStream(file.getAbsolutePath());
-            BufferedInputStream bis = new BufferedInputStream(fis);
+            bis = new BufferedInputStream(fis);
             if (container != null)
                 loader = container.getLoader();
             if (loader != null)
@@ -380,13 +381,19 @@
             return;
         } catch (IOException e) {
             log.error(sm.getString("standardManager.loading.ioe", e), e);
-            if (ois != null) {
+            if (fis != null) {
                 try {
-                    ois.close();
+                    fis.close();
+                } catch (IOException f) {
+                    // Ignore
+                }
+            }
+            if (bis != null) {
+                try {
+                    bis.close();
                 } catch (IOException f) {
                     // Ignore
                 }
-                ois = null;
             }
             throw e;
         }
@@ -408,31 +415,24 @@
                 }
             } catch (ClassNotFoundException e) {
                 log.error(sm.getString("standardManager.loading.cnfe", e), e);
-                if (ois != null) {
-                    try {
-                        ois.close();
-                    } catch (IOException f) {
-                        // Ignore
-                    }
-                    ois = null;
+                try {
+                    ois.close();
+                } catch (IOException f) {
+                    // Ignore
                 }
                 throw e;
             } catch (IOException e) {
                 log.error(sm.getString("standardManager.loading.ioe", e), e);
-                if (ois != null) {
-                    try {
-                        ois.close();
-                    } catch (IOException f) {
-                        // Ignore
-                    }
-                    ois = null;
+                try {
+                    ois.close();
+                } catch (IOException f) {
+                    // Ignore
                 }
                 throw e;
             } finally {
                 // Close the input stream
                 try {
-                    if (ois != null)
-                        ois.close();
+                    ois.close();
                 } catch (IOException f) {
                     // ignored
                 }
@@ -499,13 +499,12 @@
             oos = new ObjectOutputStream(new BufferedOutputStream(fos));
         } catch (IOException e) {
             log.error(sm.getString("standardManager.unloading.ioe", e), e);
-            if (oos != null) {
+            if (fos != null) {
                 try {
-                    oos.close();
+                    fos.close();
                 } catch (IOException f) {
                     // Ignore
                 }
-                oos = null;
             }
             throw e;
         }
@@ -527,13 +526,10 @@
                 }
             } catch (IOException e) {
                 log.error(sm.getString("standardManager.unloading.ioe", e), e);
-                if (oos != null) {
-                    try {
-                        oos.close();
-                    } catch (IOException f) {
-                        // Ignore
-                    }
-                    oos = null;
+                try {
+                    oos.close();
+                } catch (IOException f) {
+                    // Ignore
                 }
                 throw e;
             }
@@ -542,18 +538,12 @@
         // Flush and close the output stream
         try {
             oos.flush();
-            oos.close();
-            oos = null;
-        } catch (IOException e) {
-            if (oos != null) {
-                try {
-                    oos.close();
-                } catch (IOException f) {
-                    // Ignore
-                }
-                oos = null;
+        } finally {
+            try {
+                oos.close();
+            } catch (IOException f) {
+                // Ignore
             }
-            throw e;
         }
 
         // Expire all the sessions we just wrote



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to