activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: NO-JIRA Fix minor leak in FileMoveManagerTest
Date Tue, 13 Nov 2018 22:37:10 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 366005e44 -> 699591ee9


NO-JIRA Fix minor leak in FileMoveManagerTest

Not closing the InputStream makes this test flaky on Windows. The test
breaks because FileMoveManager::delete(java.io.File) Line 221 fails
to delete the file if it's still "owned" by the JVM process on Windows.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/32fd445d
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/32fd445d
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/32fd445d

Branch: refs/heads/master
Commit: 32fd445dd263250f3afa065059b178d0f352c77b
Parents: 366005e
Author: Andreas Frohwerk <andreas.frohwerk@gmail.com>
Authored: Tue Nov 13 22:23:44 2018 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Nov 13 17:36:48 2018 -0500

----------------------------------------------------------------------
 .../artemis/core/server/files/FileMoveManagerTest.java   | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/32fd445d/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
index bf8cfb2..bb062fc 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
@@ -352,11 +352,12 @@ public class FileMoveManagerTest {
 
    private void checkFile(File bkpFolder, String file) throws IOException {
       File fileRead = new File(bkpFolder, file);
-      InputStreamReader stream = new InputStreamReader(new FileInputStream(fileRead));
-      BufferedReader reader = new BufferedReader(stream);
-      String valueRead = reader.readLine();
-      int id = Integer.parseInt(file.substring(0, file.indexOf('.')));
-      Assert.assertEquals("content of the file wasn't the expected", id, Integer.parseInt(valueRead));
+      try (InputStreamReader stream = new InputStreamReader(new FileInputStream(fileRead)))
{
+         BufferedReader reader = new BufferedReader(stream);
+         String valueRead = reader.readLine();
+         int id = Integer.parseInt(file.substring(0, file.indexOf('.')));
+         Assert.assertEquals("content of the file wasn't the expected", id, Integer.parseInt(valueRead));
+      }
    }
 
 }


Mime
View raw message