From: markt Date: Sun, 7 Feb 2010 22:16:40 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48643 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dca57644ec90972c56537d62c5ac8e95cbe32d96;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48643 Clean up git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@907502 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/session/FileStore.java b/java/org/apache/catalina/session/FileStore.java index 6eafdfb3d..28da3441f 100644 --- a/java/org/apache/catalina/session/FileStore.java +++ b/java/org/apache/catalina/session/FileStore.java @@ -258,12 +258,13 @@ public final class FileStore extends StoreBase { } 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 @@ public final class FileStore extends StoreBase { 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 @@ public final class FileStore extends StoreBase { 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 @@ public final class FileStore extends StoreBase { 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 } diff --git a/java/org/apache/catalina/session/StandardManager.java b/java/org/apache/catalina/session/StandardManager.java index 25f527928..bbfdfc096 100644 --- a/java/org/apache/catalina/session/StandardManager.java +++ b/java/org/apache/catalina/session/StandardManager.java @@ -355,12 +355,13 @@ public class StandardManager 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 @@ public class StandardManager 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 @@ public class StandardManager } } 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 @@ public class StandardManager 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 @@ public class StandardManager } } 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 @@ public class StandardManager // 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