Author: kkolinko
Date: Sun Jun 17 08:02:25 2012
New Revision: 1351068
URL: http://svn.apache.org/viewvc?rev=1351068&view=rev
Log:
Properly close input streams in TestNamingContext.
This error was noticeable when running the test on Windows,
because after-test cleanup (LoggingBaseTest.deleteOnTearDown) could not remove
the files
created by this testcase.
Modified:
tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java
Modified: tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java?rev=1351068&r1=1351067&r2=1351068&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java
(original)
+++ tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java Sun
Jun 17 08:02:25 2012
@@ -19,6 +19,7 @@ package org.apache.naming.resources;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PrintWriter;
import javax.naming.Binding;
@@ -156,7 +157,13 @@ public class TestNamingContext extends T
byte[] buffer = new byte[4096];
Resource res = (Resource)file;
- int len = res.streamContent().read(buffer);
+ InputStream is = res.streamContent();
+ int len;
+ try {
+ len = is.read(buffer);
+ } finally {
+ is.close();
+ }
String contents = new String(buffer, 0, len, "UTF-8");
assertEquals(foxText, contents);
@@ -168,7 +175,12 @@ public class TestNamingContext extends T
Assert.assertTrue(file instanceof Resource);
res = (Resource)file;
- len = res.streamContent().read(buffer);
+ is = res.streamContent();
+ try {
+ len = is.read(buffer);
+ } finally {
+ is.close();
+ }
contents = new String(buffer, 0, len, "UTF-8");
assertEquals(loremIpsum, contents);
@@ -186,7 +198,12 @@ public class TestNamingContext extends T
Assert.assertTrue(file instanceof Resource);
res = (Resource)file;
- len = res.streamContent().read(buffer);
+ is = res.streamContent();
+ try {
+ len = is.read(buffer);
+ } finally {
+ is.close();
+ }
contents = new String(buffer, 0, len, "UTF-8");
assertEquals(foxText, contents);
@@ -198,7 +215,12 @@ public class TestNamingContext extends T
Assert.assertTrue(file instanceof Resource);
res = (Resource)file;
- len = res.streamContent().read(buffer);
+ is = res.streamContent();
+ try {
+ len = is.read(buffer);
+ } finally {
+ is.close();
+ }
contents = new String(buffer, 0, len, "UTF-8");
assertEquals(loremIpsum, contents);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]