Author: kkolinko Date: Sun Jun 17 08:11:17 2012 New Revision: 1351069 URL: http://svn.apache.org/viewvc?rev=1351069&view=rev Log: Merged revision 1351068 from tomcat/trunk: Properly close input streams in TestNamingContext.testAliases().
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 in the output/test-tmp directory. Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1351068 Modified: tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java?rev=1351069&r1=1351068&r2=1351069&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java Sun Jun 17 08:11:17 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); Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1351069&r1=1351068&r2=1351069&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Jun 17 08:11:17 2012 @@ -67,6 +67,12 @@ (markt) </fix> </subsection> + <subsection name="Other"> + <fix> + Fix cleanup of temporary files in <code>TestNamingContext</code> test. + (kkolinko) + </fix> + </subsection> </section> <section name="Tomcat 7.0.28 (markt)"> <subsection name="Catalina"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org