You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/03/26 12:36:46 UTC
svn commit: r1581789 - in /tomcat/trunk: TOMCAT-NEXT.txt
java/org/apache/catalina/session/FileStore.java
Author: markt
Date: Wed Mar 26 11:36:45 2014
New Revision: 1581789
URL: http://svn.apache.org/r1581789
Log:
More try-with-resources
Modified:
tomcat/trunk/TOMCAT-NEXT.txt
tomcat/trunk/java/org/apache/catalina/session/FileStore.java
Modified: tomcat/trunk/TOMCAT-NEXT.txt
URL: http://svn.apache.org/viewvc/tomcat/trunk/TOMCAT-NEXT.txt?rev=1581789&r1=1581788&r2=1581789&view=diff
==============================================================================
--- tomcat/trunk/TOMCAT-NEXT.txt (original)
+++ tomcat/trunk/TOMCAT-NEXT.txt Wed Mar 26 11:36:45 2014
@@ -214,7 +214,7 @@ but possibly 7.1.x).
- Use of try with resources
- Started.
- javax.* complete
- - o.a.catalina.[ant to security] complete
+ - o.a.catalina.[ant to servlets] complete
- remainder TODO
- Catching multiple exceptions
- Started
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=1581789&r1=1581788&r2=1581789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/FileStore.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/FileStore.java Wed Mar 26 11:36:45 2014
@@ -243,15 +243,12 @@ public final class FileStore extends Sto
id, file.getAbsolutePath()));
}
- FileInputStream fis = null;
- BufferedInputStream bis = null;
ObjectInputStream ois = null;
Loader loader = null;
ClassLoader classLoader = null;
ClassLoader oldThreadContextCL = Thread.currentThread().getContextClassLoader();
- try {
- fis = new FileInputStream(file.getAbsolutePath());
- bis = new BufferedInputStream(fis);
+ try (FileInputStream fis = new FileInputStream(file.getAbsolutePath());
+ BufferedInputStream bis = new BufferedInputStream(fis)) {
Context context = manager.getContext();
if (context != null)
loader = context.getLoader();
@@ -273,22 +270,6 @@ public final class FileStore extends Sto
if (manager.getContext().getLogger().isDebugEnabled())
manager.getContext().getLogger().debug("No persisted data file found");
return (null);
- } catch (IOException e) {
- if (bis != null) {
- try {
- bis.close();
- } catch (IOException f) {
- // Ignore
- }
- }
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException f) {
- // Ignore
- }
- }
- throw e;
} finally {
if (ois != null) {
// Close the input stream
@@ -348,28 +329,11 @@ public final class FileStore extends Sto
manager.getContext().getLogger().debug(sm.getString(getStoreName()+".saving",
session.getIdInternal(), file.getAbsolutePath()));
}
- FileOutputStream fos = null;
- ObjectOutputStream oos = null;
- try {
- fos = new FileOutputStream(file.getAbsolutePath());
- oos = new ObjectOutputStream(new BufferedOutputStream(fos));
- } catch (IOException e) {
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException f) {
- // Ignore
- }
- }
- throw e;
- }
- try {
+ try (FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
+ ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(fos))) {
((StandardSession)session).writeObjectData(oos);
- } finally {
- oos.close();
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org