activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: NO-JIRA Fix minor leak in FileMoveManagerTest
Date Wed, 14 Nov 2018 20:27:38 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 173b21e6e -> 41e79470a


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.

(cherry picked from commit 32fd445dd263250f3afa065059b178d0f352c77b)


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

Branch: refs/heads/2.6.x
Commit: 41e79470ad0fd0baa2b12e153221684d02f1f630
Parents: 173b21e
Author: Andreas Frohwerk <andreas.frohwerk@gmail.com>
Authored: Tue Nov 13 22:23:44 2018 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Nov 14 15:27:30 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/41e79470/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