db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1728370 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RawDBReaderTest.java
Date Wed, 03 Feb 2016 20:36:03 GMT
Author: kahatlen
Date: Wed Feb  3 20:36:03 2016
New Revision: 1728370

URL: http://svn.apache.org/viewvc?rev=1728370&view=rev
Log:
DERBY-6864: RawDBReaderTest fails on Windows

RawDBReaderTest.runRecoveryScript() opens a FileReader, but doesn't
close it. When the test harness tries to delete the test directory
upon completion of the test, it fails because one of the files in the
directory is still open.

This patch makes runRecoveryScript() open the FileReader in a
try-with-resources statement, so that it is automatically closed when
it goes out of scope.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RawDBReaderTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RawDBReaderTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RawDBReaderTest.java?rev=1728370&r1=1728369&r2=1728370&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RawDBReaderTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RawDBReaderTest.java
Wed Feb  3 20:36:03 2016
@@ -21,9 +21,9 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
-import java.io.LineNumberReader;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
@@ -283,24 +283,25 @@ public class RawDBReaderTest extends Gen
 
     private void    runRecoveryScript( Connection conn ) throws Exception
     {
-        File                script = new File( RECOVERY_SCRIPT );
-        LineNumberReader    reader = new LineNumberReader( new FileReader( script ) );
-
-        while ( true )
+        try (BufferedReader reader =
+                new BufferedReader(new FileReader(RECOVERY_SCRIPT)))
         {
-            String  line = reader.readLine();
-            if ( line == null ) { break; }
-
-            // skip the initial connection statement
-            // as well as comments and blank lines
-            if ( line.length() == 0 ) { continue; }
-            if ( line.startsWith( "connect" ) ) { continue; }
-            if ( line.startsWith( "--" ) ) { continue; }
+            while ( true )
+            {
+                String  line = reader.readLine();
+                if ( line == null ) { break; }
+
+                // skip the initial connection statement
+                // as well as comments and blank lines
+                if ( line.length() == 0 ) { continue; }
+                if ( line.startsWith( "connect" ) ) { continue; }
+                if ( line.startsWith( "--" ) ) { continue; }
 
-            // strip off the trailing semi-colon
-            line = line.substring( 0, line.indexOf( ';' ) );
+                // strip off the trailing semi-colon
+                line = line.substring( 0, line.indexOf( ';' ) );
 
-            goodStatement( conn, line );
+                goodStatement( conn, line );
+            }
         }
     }
 



Mime
View raw message