Skip to content

Commit cbf9adc

Browse files
author
Nico Verwer
committed
Merge branch 'develop-6.x.x' into JB-current
2 parents e41f58e + 024276e commit cbf9adc

23 files changed

+1063
-429
lines changed

.github/workflows/ci-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
with:
1212
fetch-depth: 1
1313
- name: Set up JDK 8
14-
uses: actions/setup-java@v3
14+
uses: actions/setup-java@v4
1515
with:
1616
distribution: temurin
1717
java-version: '8'
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
install: true
2323
- name: Cache Maven packages
24-
uses: actions/cache@v3
24+
uses: actions/cache@v4
2525
with:
2626
path: ~/.m2
2727
key: deploy-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

.github/workflows/ci-test.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: actions/setup-java@v3
14+
- uses: actions/setup-java@v4
1515
with:
1616
distribution: temurin
1717
java-version: ${{ env.DEV_JDK }}
@@ -23,34 +23,44 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v4
26-
- uses: actions/setup-java@v3
26+
- uses: actions/setup-java@v4
2727
with:
2828
distribution: temurin
2929
java-version: ${{ env.DEV_JDK }}
3030
cache: 'maven'
31-
- run: mvn -V -B dependency-check:check
31+
- name: OWASP dependency check
32+
env:
33+
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
34+
run: mvn -V -B dependency-check:check
3235
timeout-minutes: 60
3336
test:
3437
name: ${{ matrix.os }} Test
3538
strategy:
3639
fail-fast: false
3740
matrix:
3841
os: [ubuntu-latest, windows-latest, macOS-latest]
42+
jvm: ['8']
43+
exclude:
44+
- os: macOS-latest
45+
jvm: '8'
46+
include:
47+
- os: macOS-latest
48+
jvm: '11'
3949
runs-on: ${{ matrix.os }}
4050
steps:
4151
- uses: actions/checkout@v4
4252
- name: Set up JDK
43-
uses: actions/setup-java@v3
53+
uses: actions/setup-java@v4
4454
with:
4555
distribution: temurin
46-
java-version: ${{ env.DEV_JDK }}
56+
java-version: ${{ matrix.jvm }}
4757
cache: 'maven'
4858
- name: Install Maven Daemon
4959
id: install-mvnd
5060
uses: ./.github/actions/install-mvnd
5161
with:
52-
version: '1.0-m7'
53-
file-version-suffix: '-m39'
62+
version: '1.0.1'
63+
file-version-suffix: ''
5464
cache: 'true'
5565
- name: Maven Build
5666
timeout-minutes: 10
@@ -72,7 +82,7 @@ jobs:
7282
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B jacoco:report coveralls:report
7383
- name: Archive build logs
7484
if: always()
75-
uses: actions/upload-artifact@v3
85+
uses: actions/upload-artifact@v4
7686
with:
7787
name: ${{ runner.os }}-build-logs
7888
retention-days: 5

.github/workflows/ci-xqts.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- name: Set up JDK 8
13-
uses: actions/setup-java@v3
13+
uses: actions/setup-java@v4
1414
with:
1515
distribution: temurin
1616
java-version: '8'
1717
- name: Cache Maven packages
18-
uses: actions/cache@v3
18+
uses: actions/cache@v4
1919
with:
2020
path: ~/.m2
2121
key: xqts-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -29,22 +29,22 @@ jobs:
2929
run: find exist-xqts/target -name exist-xqts-runner.sh -exec {} --xqts-version HEAD --output-dir /tmp/xqts-output --exclude-test-case RangeExpr-411d,RangeExpr-409d,RangeExpr-408d,RangeExpr-409c,RangeExpr-408c,GenCompEq-21 \;
3030
- name: Check for HeapDump
3131
id: check_heapdump
32-
uses: andstor/file-existence-action@v2
32+
uses: andstor/file-existence-action@v3
3333
with:
3434
files: "/tmp/*.hprof"
3535
- name: Compress HeapDump
3636
if: steps.check_heapdump.outputs.files_exists == 'true'
3737
run: zstd --rm -9 --progress -T0 /tmp/*.hprof
3838
- name: Attach HeapDump artifact
3939
if: steps.check_heapdump.outputs.files_exists == 'true'
40-
uses: actions/upload-artifact@v3
40+
uses: actions/upload-artifact@v4
4141
with:
4242
name: exist-xqts-runner-hprof
4343
retention-days: 1
4444
path: /tmp/*.hprof.zst
4545
- name: Archive XQTS Logs
4646
if: always()
47-
uses: actions/upload-artifact@v3
47+
uses: actions/upload-artifact@v4
4848
with:
4949
name: xqts-logs
5050
retention-days: 14

exist-core/pom.xml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<dependency>
6060
<groupId>com.fasterxml.jackson.core</groupId>
6161
<artifactId>jackson-core</artifactId>
62-
<version>2.13.4</version>
62+
<version>2.15.2</version>
6363
</dependency>
6464

6565
<!-- dependency>
@@ -145,7 +145,7 @@
145145
<dependency>
146146
<groupId>org.bouncycastle</groupId>
147147
<artifactId>bcprov-jdk18on</artifactId>
148-
<version>1.77</version>
148+
<version>1.78.1</version>
149149
</dependency>
150150

151151
<dependency>
@@ -338,7 +338,13 @@
338338
<dependency>
339339
<groupId>xalan</groupId>
340340
<artifactId>xalan</artifactId>
341-
<version>2.7.2</version> <!-- needed an compile time for various dependencies -->
341+
<version>2.7.3</version> <!-- needed an compile time for various dependencies -->
342+
</dependency>
343+
344+
<dependency>
345+
<groupId>xalan</groupId>
346+
<artifactId>serializer</artifactId>
347+
<version>2.7.3</version>
342348
</dependency>
343349

344350
<dependency>
@@ -514,6 +520,11 @@
514520
<artifactId>assertj-core</artifactId>
515521
<scope>test</scope>
516522
</dependency>
523+
<dependency>
524+
<groupId>org.awaitility</groupId>
525+
<artifactId>awaitility</artifactId>
526+
<scope>test</scope>
527+
</dependency>
517528
<dependency>
518529
<groupId>org.easymock</groupId>
519530
<artifactId>easymock</artifactId>
@@ -560,7 +571,7 @@
560571
<dependency>
561572
<groupId>commons-fileupload</groupId>
562573
<artifactId>commons-fileupload</artifactId>
563-
<version>1.4</version>
574+
<version>1.5</version>
564575
</dependency>
565576
<dependency>
566577
<!--
@@ -955,6 +966,7 @@ The BaseX Team. The original license statement is also included below.]]></pream
955966
<ignoredUnusedDeclaredDependency>org.fusesource.jansi:jansi:jar:${jansi.version}</ignoredUnusedDeclaredDependency>
956967
<ignoredUnusedDeclaredDependency>net.sourceforge.nekohtml:nekohtml:jar:1.9.22</ignoredUnusedDeclaredDependency>
957968
<ignoredUnusedDeclaredDependency>xml-resolver:xml-resolver:jar:1.2</ignoredUnusedDeclaredDependency>
969+
<ignoredUnusedDeclaredDependency>xalan:serializer:jar:2.7.3</ignoredUnusedDeclaredDependency>
958970
<ignoredUnusedDeclaredDependency>org.xmlresolver:xmlresolver:jar:${xmlresolver.version}</ignoredUnusedDeclaredDependency>
959971
<ignoredUnusedDeclaredDependency>org.exist-db.thirdparty.org.eclipse.wst.xml:xpath2:jar:1.2.0</ignoredUnusedDeclaredDependency>
960972
<ignoredUnusedDeclaredDependency>edu.princeton.cup:java-cup:jar:10k</ignoredUnusedDeclaredDependency>

exist-core/src/main/java/org/exist/util/io/ContentFilePool.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
2727
import org.exist.util.Configuration;
2828

29+
import javax.annotation.Nullable;
30+
2931
/**
3032
* Generic pool for {@link ContentFile} instances used to represent RPC server data up to a defined size in memory first
3133
* before storing the data in the file system using the {@link TemporaryFileManager}.
@@ -50,23 +52,25 @@ public final class ContentFilePool extends GenericObjectPool<ContentFile> {
5052
* Creates a new pool using the givem temporary file manager, configuration and maximum idle time.
5153
*
5254
* @param tempFileManager the temporary file manager used when need to swap out data bigger than max in memory size
55+
* @param brokerId the optional broker id
5356
* @param config the configuration used to configure the main pool properties
5457
*/
55-
public ContentFilePool(final TemporaryFileManager tempFileManager, final Configuration config) {
56-
super(new ContentFilePoolObjectFactory(tempFileManager, toInMemorySize(config)), toPoolConfig(config));
58+
public ContentFilePool(final TemporaryFileManager tempFileManager, @Nullable final String brokerId, final Configuration config) {
59+
super(new ContentFilePoolObjectFactory(tempFileManager, toInMemorySize(config)), toPoolConfig(brokerId, config));
5760
}
5861

5962
private static int toInMemorySize(final Configuration config) {
6063
return config.getInteger(PROPERTY_IN_MEMORY_SIZE, VirtualTempPath.DEFAULT_IN_MEMORY_SIZE);
6164
}
6265

63-
private static GenericObjectPoolConfig<ContentFile> toPoolConfig(final Configuration config) {
66+
private static GenericObjectPoolConfig<ContentFile> toPoolConfig(@Nullable final String brokerId, final Configuration config) {
6467
final GenericObjectPoolConfig<ContentFile> poolConfig = new GenericObjectPoolConfig<>();
6568
poolConfig.setBlockWhenExhausted(false);
6669
poolConfig.setLifo(true);
6770
poolConfig.setMaxIdle(config.getInteger(PROPERTY_POOL_MAX_IDLE));
6871
poolConfig.setMaxTotal(config.getInteger(PROPERTY_POOL_SIZE));
69-
poolConfig.setJmxNameBase("org.exist.management.exist:type=ContentFilePool");
72+
final String poolName = brokerId == null ? "" : "pool." + brokerId;
73+
poolConfig.setJmxNameBase("org.exist.management.exist:type=ContentFilePool,name=" + poolName);
7074
return poolConfig;
7175
}
7276

exist-core/src/main/java/org/exist/util/io/MemoryContentsInputStream.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import java.io.IOException;
2828
import java.io.InputStream;
29-
import java.io.OutputStream;
3029
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
3130

3231
/**
@@ -84,7 +83,7 @@ public int read() throws IOException {
8483
public int read(byte[] b, int off, int len) throws IOException {
8584
boolean success = false;
8685
int read = 0;
87-
while (!success) {
86+
while (!success && len > 0) {
8887
long positionBefore = POSITION_UPDATER.get(this);
8988
read = this.memoryContents.read(b, positionBefore, off, len);
9089
if (read < 1) {
@@ -115,13 +114,4 @@ public long skip(long n) throws IOException {
115114
}
116115
return skipped;
117116
}
118-
119-
// Java 9 method, has to compile under Java 1.7 so no @Override
120-
public long transferTo(OutputStream out) throws IOException {
121-
long positionBefore = POSITION_UPDATER.get(this);
122-
long written = this.memoryContents.transferTo(out, positionBefore);
123-
POSITION_UPDATER.set(this, this.memoryContents.size());
124-
return written;
125-
}
126-
127117
}

exist-core/src/main/java/org/exist/util/io/VirtualTempPath.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public final class VirtualTempPath implements ContentFile {
5252
@GuardedBy("lock")
5353
private Path contentFile;
5454

55+
public VirtualTempPath(TemporaryFileManager tempFileManager) {
56+
this(DEFAULT_IN_MEMORY_SIZE, tempFileManager);
57+
}
58+
5559
public VirtualTempPath(int inMemorySize, TemporaryFileManager tempFileManager) {
5660
this.inMemorySize = inMemorySize;
5761
this.lock = new StampedLock();
@@ -97,6 +101,7 @@ public OutputStream newOutputStream() throws IOException {
97101
}
98102
}
99103

104+
@Override
100105
public InputStream newInputStream() throws IOException {
101106
long stamp = lock.readLock();
102107
try {
@@ -129,6 +134,7 @@ public void close() {
129134
}
130135
}
131136

137+
@Override
132138
public long size() {
133139
long stamp = lock.readLock();
134140
try {
@@ -141,6 +147,7 @@ public long size() {
141147
}
142148
}
143149

150+
@Override
144151
public byte[] getBytes() {
145152
long stamp = lock.readLock();
146153
try {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* eXist-db Open Source Native XML Database
3+
* Copyright (C) 2001 The eXist-db Authors
4+
*
5+
6+
* http://www.exist-db.org
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public
19+
* License along with this library; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
*/
22+
package org.exist.xmlrpc;
23+
24+
import org.exist.util.io.ContentFile;
25+
26+
import java.util.function.Consumer;
27+
28+
/**
29+
* @author <a href="mailto:[email protected]">Patrick Reinhart</a>
30+
*/
31+
final class CachedContentFile extends AbstractCachedResult {
32+
private final ContentFile result;
33+
private final Consumer<ContentFile> poolConsumer;
34+
35+
CachedContentFile(final ContentFile result, final Consumer<ContentFile> poolConsumer) {
36+
super(0);
37+
this.result = result;
38+
this.poolConsumer = poolConsumer;
39+
}
40+
41+
@Override
42+
public ContentFile getResult() {
43+
return result;
44+
}
45+
46+
@Override
47+
protected void doClose() {
48+
if (result != null) {
49+
poolConsumer.accept(result);
50+
result.close();
51+
}
52+
}
53+
}

exist-core/src/main/java/org/exist/xmlrpc/QueryResultCache.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public QueryResultCache() {
5151
.expireAfterAccess(TIMEOUT, TimeUnit.MILLISECONDS)
5252
.removalListener((key, value, cause) -> {
5353
final AbstractCachedResult qr = (AbstractCachedResult)value;
54-
qr.free(); // must free associated resources
54+
qr.close(); // must close associated resources
5555
if(LOG.isDebugEnabled()) {
56-
LOG.debug("Removing cached result set: {}", new Date(qr.getTimestamp()).toString());
56+
LOG.debug("Removing cached result set: {}", new Date(qr.getTimestamp()));
5757
}
5858
}).build();
5959
}
@@ -81,6 +81,11 @@ public SerializedResult getSerializedResult(final int cacheId) {
8181
return (acr != null && acr instanceof SerializedResult) ? (SerializedResult) acr : null;
8282
}
8383

84+
public CachedContentFile getCachedContentFile(final int cacheId) {
85+
final AbstractCachedResult acr = get(cacheId);
86+
return (acr != null && acr instanceof CachedContentFile) ? (CachedContentFile) acr : null;
87+
}
88+
8489
public void remove(final int cacheId) {
8590
if (cacheId < 0 || cacheId >= cacheIdCounter.get()) {
8691
return; // out of scope

0 commit comments

Comments
 (0)