Skip to content

Commit fe946da

Browse files
committed
[bugfix] Fixes sonar issues
1 parent eb13b71 commit fe946da

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

exist-core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,11 @@
514514
<artifactId>assertj-core</artifactId>
515515
<scope>test</scope>
516516
</dependency>
517+
<dependency>
518+
<groupId>org.awaitility</groupId>
519+
<artifactId>awaitility</artifactId>
520+
<scope>test</scope>
521+
</dependency>
517522
<dependency>
518523
<groupId>org.easymock</groupId>
519524
<artifactId>easymock</artifactId>

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

Lines changed: 2 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
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3049,7 +3049,7 @@ private List<List<Object>> getIndexedElements(final XmldbURI collUri,
30493049
return this.<List<List<Object>>>readCollection(collUri).apply((collection, broker, transaction) -> {
30503050
final ElementIndex elementIndex = broker.getElementIndex();
30513051
if (elementIndex != null) {
3052-
final Occurrences occurrences[] = elementIndex.scanIndexedElements(collection, inclusive);
3052+
final Occurrences[] occurrences = elementIndex.scanIndexedElements(collection, inclusive);
30533053
final List<List<Object>> result = new ArrayList<>(occurrences.length);
30543054
for (final Occurrences occurrence : occurrences) {
30553055
final QName qname = (QName) occurrence.getTerm();

exist-core/src/test/java/org/exist/xmlrpc/QueryResultCacheTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.junit.jupiter.api.BeforeEach;
2525
import org.junit.jupiter.api.Test;
2626

27+
import static java.util.concurrent.TimeUnit.SECONDS;
2728
import static org.assertj.core.api.Assertions.*;
29+
import static org.awaitility.Awaitility.await;
2830

2931
/**
3032
* @author <a href="mailto:[email protected]">Patrick Reinhart</a>
@@ -71,8 +73,8 @@ void testGetCachedContentFile() {
7173
void testRemove() throws InterruptedException {
7274
assertThatNoException().isThrownBy(() -> cache.remove(-1));
7375
assertThatNoException().isThrownBy(() -> cache.remove(0));
74-
Thread.sleep(400);
75-
assertThat(cachedResult.getResult()).isOne();
76+
77+
await().atMost(1, SECONDS).untilAsserted(() -> assertThat(cachedResult.getResult()).isOne());
7678
assertThatNoException().isThrownBy(() -> cache.remove(1));
7779
}
7880

@@ -82,8 +84,8 @@ void testRemoveWithHashCode() throws InterruptedException {
8284
assertThatNoException().isThrownBy(() -> cache.remove(0, 0));
8385
assertThat(cachedResult.getResult()).isZero();
8486
assertThatNoException().isThrownBy(() -> cache.remove(0, 42));
85-
Thread.sleep(400);
86-
assertThat(cachedResult.getResult()).isOne();
87+
88+
await().atMost(1, SECONDS).untilAsserted(() -> assertThat(cachedResult.getResult()).isOne());
8789
assertThatNoException().isThrownBy(() -> cache.remove(1, 0));
8890
}
8991

exist-core/src/test/java/org/exist/xmlrpc/XmlRpcTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,7 @@ public void testExecuteQuery() throws XmlRpcException, MalformedURLException {
612612
params.clear();
613613
params.add(handle);
614614
Integer hits = (Integer) xmlrpc.execute("getHits", params);
615-
assertThat(hits).isNotNull();
616-
617-
assertThat(hits).isEqualTo(2);
615+
assertThat(hits).isNotNull().isEqualTo(2);
618616

619617
params.add(0);
620618
params.add(new HashMap());
@@ -910,7 +908,7 @@ public void testGetSubCollectionCreationTime() throws XmlRpcException, Malformed
910908
List<Object> params = new ArrayList<>();
911909
params.add("/db");
912910
params.add("xmlrpc");
913-
assertThat((Long)xmlrpc.execute("getSubCollectionCreationTime", params)).isGreaterThan(0);
911+
assertThat((Long)xmlrpc.execute("getSubCollectionCreationTime", params)).isPositive();
914912
}
915913

916914
@Test

exist-parent/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<easymock.version>5.2.0</easymock.version>
126126
<objenesis.version>3.3</objenesis.version>
127127
<assertj.version>3.25.3</assertj.version>
128+
<awaitility.version>4.2.0</awaitility.version>
128129
<junit.toolbox.version>2.4</junit.toolbox.version>
129130
<hamcrest.version>2.2</hamcrest.version>
130131

@@ -531,6 +532,12 @@
531532
<version>${assertj.version}</version>
532533
<scope>test</scope>
533534
</dependency>
535+
<dependency>
536+
<groupId>org.awaitility</groupId>
537+
<artifactId>awaitility</artifactId>
538+
<version>${awaitility.version}</version>
539+
<scope>test</scope>
540+
</dependency>
534541
<dependency>
535542
<groupId>org.easymock</groupId>
536543
<artifactId>easymock</artifactId>

0 commit comments

Comments
 (0)