You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2025/06/13 12:50:13 UTC
(causeway) 01/01: Merge remote-tracking branch 'origin/main' into v4
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v4
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 752ffc0d3ce56abc23d21654400fca865aea0809
Merge: 2e656191d9c d589bafcdb3
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Jun 13 14:50:07 2025 +0200
Merge remote-tracking branch 'origin/main' into v4
commons/src/main/java/module-info.java | 1 +
.../commons/internal/debug/_MemoryUsage.java | 98 +++++++++++++
.../metamodel/context/HasMetaModelContext.java | 5 +
.../context/MetaModelContext_usingSpring.java | 5 +
.../metamodel/spec/impl/ObjectMemberAbstract.java | 5 -
.../runtimeservices/src/main/java/module-info.java | 1 +
.../pdfjs/wkt/ui/components/PdfJsViewerPanel.java | 20 +--
.../testdomain/jpa/JpaInventoryManager.java | 6 +
.../interact/WrapperInteraction_1_IntegTest.java | 149 +++++++++++++++++++
.../interact/WrapperInteraction_2_IntegTest.java | 132 +++++++++++++++++
.../interact/WrapperInteraction_3_IntegTest.java | 158 +++++++++++++++++++++
.../interact/WrapperInteraction_4_IntegTest.java | 152 ++++++++++++++++++++
.../WrapperInteraction_Caching_IntegTest.java | 141 ++++++++++++++++++
.../jpa/wrapper/JpaWrapperSyncTest.java | 86 +++++++++++
.../WrapperFactoryMetaspaceMemoryLeakTest.java | 103 ++++++++++++++
15 files changed, 1049 insertions(+), 13 deletions(-)
diff --cc commons/src/main/java/module-info.java
index dc27edec287,27b06a6870d..fd5cc6fdc27
--- a/commons/src/main/java/module-info.java
+++ b/commons/src/main/java/module-info.java
@@@ -66,6 -66,7 +66,7 @@@ module org.apache.causeway.commons
requires transitive java.desktop;
requires transitive java.sql;
requires transitive java.xml;
- requires transitive org.apache.logging.log4j;
++ requires transitive java.management;
requires transitive org.jdom2;
requires transitive org.jspecify;
requires transitive org.jsoup;
diff --cc regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/persistence/jpa/wrapper/JpaWrapperSyncTest.java
index 00000000000,a62821d1e69..e58358093f4
mode 000000,100644..100644
--- a/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/persistence/jpa/wrapper/JpaWrapperSyncTest.java
+++ b/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/persistence/jpa/wrapper/JpaWrapperSyncTest.java
@@@ -1,0 -1,90 +1,86 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.causeway.testdomain.persistence.jpa.wrapper;
+
+ import jakarta.inject.Inject;
+
+ import org.junit.jupiter.api.AfterEach;
+ import org.junit.jupiter.api.BeforeEach;
+ import org.junit.jupiter.api.Test;
+
+ import static org.junit.jupiter.api.Assertions.assertEquals;
+
+ import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.TestPropertySource;
-
+ import org.apache.causeway.applib.services.repository.RepositoryService;
+ import org.apache.causeway.applib.services.wrapper.WrapperFactory;
-import org.apache.causeway.core.config.presets.CausewayPresets;
+ import org.apache.causeway.testdomain.fixtures.EntityTestFixtures;
+ import org.apache.causeway.testdomain.jpa.JpaInventoryManager;
+ import org.apache.causeway.testdomain.jpa.JpaTestFixtures;
+ import org.apache.causeway.testdomain.jpa.conf.Configuration_usingJpa;
+ import org.apache.causeway.testdomain.jpa.entities.JpaBook;
+ import org.apache.causeway.testdomain.jpa.entities.JpaProduct;
+ import org.apache.causeway.testing.integtestsupport.applib.CausewayIntegrationTestAbstract;
+
+ import lombok.val;
+
+ @SpringBootTest(
+ classes = {
+ Configuration_usingJpa.class
+ },
+ properties = {
+ "spring.datasource.url=jdbc:h2:mem:JpaWrapperSyncTest"
+ }
+ )
-@TestPropertySource(CausewayPresets.UseLog4j2Test)
+ class JpaWrapperSyncTest extends CausewayIntegrationTestAbstract {
+
+ @Inject private RepositoryService repository;
+ @Inject private WrapperFactory wrapper;
+ @Inject private JpaTestFixtures testFixtures;
+
+ protected EntityTestFixtures.Lock lock;
+
+ @BeforeEach
+ void installFixture() {
+ this.lock = testFixtures.aquireLock();
+ lock.install();
+ }
+
+ @AfterEach
+ void uninstallFixture() {
+ this.lock.release();
+ }
+
+ @Test
+ void testWrapper_waitingOnDomainEvent() {
+
+ val inventoryManager = factoryService.viewModel(JpaInventoryManager.class);
+ val sumOfPrices = repository.allInstances(JpaProduct.class)
+ .stream()
+ .mapToDouble(JpaProduct::getPrice)
+ .sum();
+
+ assertEquals(167d, sumOfPrices, 1E-6);
+
+ val products = wrapper.wrap(inventoryManager).getAllProducts();
+
+ assertEquals(3, products.size());
+ assertEquals(JpaBook.class, products.get(0).getClass());
+ }
+
+ }
diff --cc regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/persistence/jpa/wrapper/WrapperFactoryMetaspaceMemoryLeakTest.java
index 00000000000,18dd21de935..c579fbfe39f
mode 000000,100644..100644
--- a/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/persistence/jpa/wrapper/WrapperFactoryMetaspaceMemoryLeakTest.java
+++ b/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/persistence/jpa/wrapper/WrapperFactoryMetaspaceMemoryLeakTest.java
@@@ -1,0 -1,107 +1,103 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.causeway.testdomain.persistence.jpa.wrapper;
+
+ import jakarta.inject.Inject;
+
+ import org.junit.jupiter.api.AfterEach;
+ import org.junit.jupiter.api.BeforeEach;
+ import org.junit.jupiter.api.Test;
+
+ import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.TestPropertySource;
-
+ import org.apache.causeway.applib.services.wrapper.WrapperFactory;
+ import org.apache.causeway.commons.internal.base._Blackhole;
+ import org.apache.causeway.commons.internal.debug._MemoryUsage;
-import org.apache.causeway.core.config.presets.CausewayPresets;
+ import org.apache.causeway.testdomain.fixtures.EntityTestFixtures;
+ import org.apache.causeway.testdomain.jpa.JpaInventoryManager;
+ import org.apache.causeway.testdomain.jpa.JpaTestFixtures;
+ import org.apache.causeway.testdomain.jpa.conf.Configuration_usingJpa;
+ import org.apache.causeway.testdomain.jpa.entities.JpaProduct;
+ import org.apache.causeway.testing.integtestsupport.applib.CausewayIntegrationTestAbstract;
+
+ @SpringBootTest(
+ classes = {
+ Configuration_usingJpa.class,
+ },
+ properties = {
+ "spring.datasource.url=jdbc:h2:mem:JpaWrapperSyncTest"
+ }
+ )
-@TestPropertySource(CausewayPresets.UseLog4j2Test)
+ class WrapperFactoryMetaspaceMemoryLeakTest extends CausewayIntegrationTestAbstract {
+
+ @Inject private WrapperFactory wrapper;
+ @Inject private JpaTestFixtures testFixtures;
+
+ protected EntityTestFixtures.Lock lock;
+
+ @BeforeEach
+ void installFixture() {
+ this.lock = testFixtures.aquireLock();
+ lock.install();
+ }
+
+ @AfterEach
+ void uninstallFixture() {
+ this.lock.release();
+ }
+
+ @Test
+ void testWrapper_waitingOnDomainEvent() throws InterruptedException {
+ _MemoryUsage.measureMetaspace("exercise", ()->{
+ // with caching
+ // exercise(1, 0); // 2,221 KB
+ // exercise(1, 2000); // 3,839 KB. // some leakage from collections
+ // exercise(20, 0); // 2,112 KB
+ // exercise(20, 2000); // 3,875 KB
+ // exercise(2000, 0); // 3,263 KB. // ? increased some, is it significant; a lot less than without caching
+ // exercise(2000, 200); // 4,294 KB.
+ // exercise(20000, 0); // 3,243 KB // no noticeable leakage compared to 2000; MUCH less than without caching
+
+ // without caching
+ // exercise(1, 0); // 2,244 KB
+ // exercise(1, 2000); //. 3,669 KB // some leakage from collections
+ // exercise(20, 0); // 2,440 KB
+ // exercise(20, 2000); //. 4,286 KB
+ exercise(2000, 0); // 14,580 KB // significant leakage from 20
+ // exercise(2000, 200); // 20,423 KB
+ // exercise(20000, 0); //.115,729 KB
+ });
+ }
+
- private void exercise(int instances, int loops) {
++ private void exercise(final int instances, final int loops) {
+ for (int i = 0; i < instances; i++) {
+ var jpaInventoryManager = wrapper.wrap(factoryService.viewModel(JpaInventoryManager.class));
+ jpaInventoryManager.foo();
+
+ for (var j = 0; j < loops; j++) {
+ jpaInventoryManager
+ .getAllProducts()
+ .stream()
+ .map(JpaProduct::getName)
+ .forEach(_Blackhole::consume);
+ }
+ }
+ }
+ }
+
+