commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: svn commit: r1573188 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
Date Sat, 01 Mar 2014 16:13:52 GMT
Shouldn't a try/finally clause be used here?

Or, move to Java 7 after 3.3 and use try-with-resources all over.

I know this is test code... but I am sure there are plenty of other bullet
proofing opportunities.

Gary


On Sat, Mar 1, 2014 at 11:11 AM, <sebb@apache.org> wrote:

> Author: sebb
> Date: Sat Mar  1 16:11:01 2014
> New Revision: 1573188
>
> URL: http://svn.apache.org/r1573188
> Log:
> Close resource
>
> Modified:
>
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
>
> Modified:
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java?rev=1573188&r1=1573187&r2=1573188&view=diff
>
> ==============================================================================
> ---
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
> (original)
> +++
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
> Sat Mar  1 16:11:01 2014
> @@ -557,12 +557,14 @@ public class StringEscapeUtilsTest {
>       */
>      @Test
>      public void testLang708() throws IOException {
> -        final String input = IOUtils.toString(new
> FileInputStream("src/test/resources/lang-708-input.txt"), "UTF-8");
> +        final FileInputStream fis = new
> FileInputStream("src/test/resources/lang-708-input.txt");
> +        final String input = IOUtils.toString(fis, "UTF-8");
>          final String escaped = StringEscapeUtils.escapeEcmaScript(input);
>          // just the end:
>          assertTrue(escaped, escaped.endsWith("}]"));
>          // a little more:
>          assertTrue(escaped,
> escaped.endsWith("\"valueCode\\\":\\\"\\\"}]"));
> +        fis.close();
>      }
>
>      /**
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message