From 10e5c7cff5d424375771e20bfeebbef509f8844b Mon Sep 17 00:00:00 2001 From: Dannes Wessels Date: Sun, 28 Jul 2024 21:55:44 +0200 Subject: [PATCH 1/4] [bugfix] Make build compatible with Java18 and beyond. --- exist-core/pom.xml | 4 ++-- extensions/modules/simpleql/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exist-core/pom.xml b/exist-core/pom.xml index a8610bc3754..8657f0c7bb3 100644 --- a/exist-core/pom.xml +++ b/exist-core/pom.xml @@ -1067,9 +1067,9 @@ The BaseX Team. The original license statement is also included below.]]> - org.codehaus.mojo + org.omnifaces antlr-maven-plugin - 2.2 + 2.3 org/exist/xquery/parser/XQuery.g,org/exist/xquery/parser/XQueryTree.g,org/exist/xquery/parser/DeclScanner.g,org/exist/xquery/xqdoc/parser/XQDocParser.g diff --git a/extensions/modules/simpleql/pom.xml b/extensions/modules/simpleql/pom.xml index 67030fdc0b2..4d18433a994 100644 --- a/extensions/modules/simpleql/pom.xml +++ b/extensions/modules/simpleql/pom.xml @@ -67,9 +67,9 @@ - org.codehaus.mojo + org.omnifaces antlr-maven-plugin - 2.2 + 2.3 org/exist/xquery/modules/simpleql/SimpleQLParser.g From 0ee9643486cfbded4f2feada2f939204971ddba1 Mon Sep 17 00:00:00 2001 From: Dannes Wessels Date: Mon, 29 Jul 2024 10:47:37 +0200 Subject: [PATCH 2/4] Add java21 build --- .github/workflows/ci-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 61d5473ac1f..8e1b9d6e3ca 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -39,6 +39,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] + jvm: ['17', '21'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -46,7 +47,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: temurin - java-version: ${{ env.DEV_JDK }} + java-version: ${{ matrix.jvm }} cache: 'maven' - name: Install Maven Daemon id: install-mvnd From b5031666dbb65936bbc7bcc865b66a4a6f738f03 Mon Sep 17 00:00:00 2001 From: Dannes Wessels Date: Mon, 29 Jul 2024 13:14:36 +0200 Subject: [PATCH 3/4] Update ci-test.yml Prevent overwrite logs --- .github/workflows/ci-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 8e1b9d6e3ca..e36beccc43d 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -78,7 +78,7 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: ${{ runner.os }}-build-logs + name: ${{ runner.os }}-${{ matrix.jvm }}-build-logs retention-days: 5 path: | **/*.jfr From 394e4aa2f755041b92b158efc84f501d35005624 Mon Sep 17 00:00:00 2001 From: Dannes Wessels Date: Tue, 30 Jul 2024 09:11:48 +0200 Subject: [PATCH 4/4] Use alternative route to check logs --- extensions/indexes/range/pom.xml | 35 ++++++++++++++++--- .../indexing/range/RangeIndexConfigTest.java | 32 ++++++----------- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/extensions/indexes/range/pom.xml b/extensions/indexes/range/pom.xml index dedd0b2ac62..62ab4ed89e8 100644 --- a/extensions/indexes/range/pom.xml +++ b/extensions/indexes/range/pom.xml @@ -24,7 +24,7 @@ --> 4.0.0 - + org.exist-db exist-parent @@ -42,8 +42,8 @@ scm:git:https://github.com/exist-db/exist.git scm:git:https://github.com/exist-db/exist.git scm:git:https://github.com/exist-db/exist.git - HEAD - + HEAD + @@ -67,7 +67,7 @@ lucene-core ${lucene.version} - + org.apache.lucene lucene-analyzers-common @@ -113,6 +113,13 @@ test + + io.github.hakky54 + logcaptor + 2.9.3 + test + + @@ -128,6 +135,26 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.logging.log4j:log4j-slf4j-impl + org.apache.logging.log4j:log4j-slf4j2-impl + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.apache.logging.log4j:log4j-slf4j-impl + org.apache.logging.log4j:log4j-slf4j2-impl + + + org.apache.maven.plugins maven-dependency-plugin diff --git a/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java b/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java index 919c1f2dbb4..0b8ea43d2c8 100644 --- a/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java +++ b/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java @@ -21,25 +21,23 @@ */ package org.exist.indexing.range; +import nl.altindag.log.LogCaptor; import org.apache.logging.log4j.Logger; import org.easymock.Capture; -import org.exist.util.JDKCompatibility; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.Map; -import static junit.framework.TestCase.assertTrue; import static org.easymock.EasyMock.*; import static org.exist.collections.CollectionConfiguration.DEFAULT_COLLECTION_CONFIG_FILE; import static org.exist.indexing.lucene.LuceneIndexConfig.MATCH_ATTR; import static org.exist.indexing.lucene.LuceneIndexConfig.QNAME_ATTR; +import static org.junit.Assert.assertTrue; public class RangeIndexConfigTest { @@ -88,30 +86,20 @@ public void errorsHaveSourceContext() throws NoSuchFieldException, IllegalAccess replay(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList, mockLogger); - final Map namespaces = new HashMap<>(); namespaces.put("tei", "http://www.tei-c.org/ns/1.0"); - overrideLogger(RangeIndexConfig.class, mockLogger); - final RangeIndexConfig config = new RangeIndexConfig(mockConfigNodes, namespaces); - - assertTrue(errorMsgCapture.getValue().contains("Illegal QName: '" + badCreateQName + "'.. QName is invalid: INVALID_LOCAL_PART")); - assertTrue(errorMsgCapture.getValue().contains("(" + mockCollectionXConfUri + ")")); + LogCaptor logCaptor = LogCaptor.forClass(RangeIndexConfig.class); - verify(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList, mockLogger); - } - - private void overrideLogger(final Class clazz, final Logger logger) throws NoSuchFieldException, IllegalAccessException { - final Field loggerField = clazz.getDeclaredField("LOG"); + final RangeIndexConfig config = new RangeIndexConfig(mockConfigNodes, namespaces); - // allow access to private field - loggerField.setAccessible(true); + assertTrue(logCaptor.getLogs().get(0) + .contains("Illegal QName: '" + badCreateQName + "'.. QName is invalid: INVALID_LOCAL_PART")); - // remove final modifier - final Field modifiersField = JDKCompatibility.getModifiersField(); - modifiersField.setAccessible(true); - modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL); + assertTrue(logCaptor.getLogs().get(0) + .contains("(" + mockCollectionXConfUri + ")")); - loggerField.set(null, logger); + verify(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList); } + }