Author: violetagg
Date: Sat Jan 2 17:33:26 2016
New Revision: 1722645
URL: http://svn.apache.org/viewvc?rev=1722645&view=rev
Log:
Simplify the code
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/session/FileStore.java
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/session/FileStore.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/session/FileStore.java?rev=1722645&r1=1722644&r2=1722645&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/session/FileStore.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/session/FileStore.java Sat
Jan 2 17:33:26 2016
@@ -291,7 +291,7 @@ public final class FileStore extends Sto
if (manager.getContainer().getLogger().isDebugEnabled())
manager.getContainer().getLogger().debug("No persisted data
file found");
return (null);
- } catch (IOException e) {
+ } finally {
if (bis != null) {
try {
bis.close();
@@ -306,8 +306,6 @@ public final class FileStore extends Sto
// Ignore
}
}
- throw e;
- } finally {
if (ois != null) {
// Close the input stream
try {
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java?rev=1722645&r1=1722644&r2=1722645&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java
Sat Jan 2 17:33:26 2016
@@ -530,28 +530,33 @@ public class FileDirContext extends Base
// Open os
+ FileOutputStream os = null;
+ byte buffer[] = new byte[BUFFER_SIZE];
+ int len = -1;
try {
- FileOutputStream os = null;
- byte buffer[] = new byte[BUFFER_SIZE];
- int len = -1;
- try {
- os = new FileOutputStream(file);
- while (true) {
- len = is.read(buffer);
- if (len == -1)
- break;
- os.write(buffer, 0, len);
- }
- } finally {
- if (os != null)
- os.close();
- is.close();
+ os = new FileOutputStream(file);
+ while (true) {
+ len = is.read(buffer);
+ if (len == -1)
+ break;
+ os.write(buffer, 0, len);
}
} catch (IOException e) {
NamingException ne = new NamingException
(sm.getString("resources.bindFailed", e));
ne.initCause(e);
throw ne;
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ }
+ }
+ try {
+ is.close();
+ } catch (IOException e) {
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]