[activemq-artemis] branch master updated: ARTEMIS-2953 - drop the use of non deterministic finalize

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[activemq-artemis] branch master updated: ARTEMIS-2953 - drop the use of non deterministic finalize

clebertsuconic-2
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new c4832c3  ARTEMIS-2953 - drop the use of non deterministic finalize
     new 0077f35  This closes #3305
c4832c3 is described below

commit c4832c320909be88766188f845adacc782d04319
Author: gtully <[hidden email]>
AuthorDate: Thu Oct 15 11:55:54 2020 +0100

    ARTEMIS-2953 - drop the use of non deterministic finalize
---
 .../org/apache/activemq/artemis/core/paging/impl/Page.java    | 11 -----------
 .../artemis/tests/unit/core/paging/impl/PageTest.java         |  9 +++++----
 .../tests/unit/core/paging/impl/PagingStoreImplTest.java      |  6 ++++++
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
index badfabf..36dfc27 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
@@ -583,17 +583,6 @@ public final class Page implements Comparable<Page> {
    }
 
    @Override
-   protected void finalize() {
-      try {
-         if (file != null && file.isOpen()) {
-            file.close(false);
-         }
-      } catch (Exception e) {
-         ActiveMQServerLogger.LOGGER.pageFinaliseError(e);
-      }
-   }
-
-   @Override
    public int hashCode() {
       final int prime = 31;
       int result = 1;
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
index 894651e..eaf0359 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
@@ -225,19 +225,20 @@ public class PageTest extends ActiveMQTestBase {
 
       file = factory.createSequentialFile("00010.page");
       file.open();
-      page = new Page(new SimpleString("something"), new NullStorageManager(), factory, file, 10);
+      Page page1 = new Page(new SimpleString("something"), new NullStorageManager(), factory, file, 10);
 
-      List<PagedMessage> msgs = page.read(new NullStorageManager());
+      List<PagedMessage> msgs = page1.read(new NullStorageManager());
 
       Assert.assertEquals(numberOfElements, msgs.size());
 
-      Assert.assertEquals(numberOfElements, page.getNumberOfMessages());
+      Assert.assertEquals(numberOfElements, page1.getNumberOfMessages());
 
       for (int i = 0; i < msgs.size(); i++) {
          Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddressSimpleString());
       }
 
-      page.delete(null);
+      page.close(false);
+      page1.delete(null);
 
       Assert.assertEquals(0, factory.listFiles("page").size());
 
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
index f1808be..7867b7c 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
@@ -179,6 +179,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
 
       Assert.assertEquals(1, storeImpl.getNumberOfPages());
 
+      storeImpl.stop();
    }
 
    @Test
@@ -226,6 +227,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
       Assert.assertEquals(numMessages, msg.size());
       Assert.assertEquals(1, storeImpl.getNumberOfPages());
 
+      page.close(false);
       page = storeImpl.depage();
 
       Assert.assertNull(page);
@@ -362,6 +364,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
       Assert.assertEquals(0, store.getNumberOfPages());
 
       page.open();
+      page.close(false);
 
    }
 
@@ -576,6 +579,8 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
       Assert.assertEquals(0, buffers2.size());
 
       Assert.assertEquals(0, storeImpl.getAddressSize());
+
+      storeImpl.stop();
    }
 
    @Test
@@ -791,6 +796,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
             Assert.assertEquals(msg.getMessageID(), msg.getLongProperty("count").longValue());
             msgsRead++;
          }
+         page.close(false);
       }
 
       storeImpl.stop();