Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

package org.eclipse.rdf4j.sail.shacl;

import java.util.NoSuchElementException;

import org.eclipse.rdf4j.common.iteration.CloseableIteration;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.repository.RepositoryResult;
import org.eclipse.rdf4j.sail.InterruptedSailException;
import org.eclipse.rdf4j.sail.SailConnection;
import org.eclipse.rdf4j.sail.SailException;

Expand Down Expand Up @@ -55,8 +58,23 @@ static void transferStatements(SailConnection from, TransferStatement transfer)
try (CloseableIteration<? extends Statement> statements = from
.getStatements(null, null, null, false)) {

while (statements.hasNext()) {
Statement next = statements.next();
while (true) {
throwIfInterrupted();
boolean hasNext = statements.hasNext();
throwIfInterrupted();
if (!hasNext) {
break;
}

Statement next;
try {
next = statements.next();
} catch (NoSuchElementException e) {
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedSailException("Thread was interrupted while transferring statements.", e);
}
throw e;
}

transfer.transfer(next.getSubject(), next.getPredicate(),
next.getObject(), next.getContext());
Expand All @@ -66,6 +84,12 @@ static void transferStatements(SailConnection from, TransferStatement transfer)

}

private static void throwIfInterrupted() {
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedSailException("Thread was interrupted while transferring statements.");
}
}

static boolean isEmpty(SailConnection connection) {
return !connection.hasStatement(null, null, null, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*******************************************************************************
* Copyright (c) 2026 Eclipse RDF4J contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
// Some portions generated by Codex

package org.eclipse.rdf4j.sail.shacl;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.NoSuchElementException;

import org.eclipse.rdf4j.common.iteration.CloseableIteration;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.sail.InterruptedSailException;
import org.eclipse.rdf4j.sail.SailConnection;
import org.junit.jupiter.api.Test;

class ConnectionHelperTest {

@Test
void transferStatementsConvertsInterruptedIterationToInterruptedSailException() {
SailConnection connection = mock(SailConnection.class);
@SuppressWarnings("unchecked")
CloseableIteration<? extends Statement> statements = mock(CloseableIteration.class);
doReturn(statements).when(connection).getStatements(isNull(), isNull(), isNull(), anyBoolean());
when(statements.hasNext()).thenReturn(true);
when(statements.next()).thenAnswer(invocation -> {
Thread.currentThread().interrupt();
throw new NoSuchElementException("The iteration has been interrupted.");
});

try {
assertThatExceptionOfType(InterruptedSailException.class)
.isThrownBy(() -> ConnectionHelper.transferStatements(connection, (subject, predicate, object,
context) -> {
throw new AssertionError("No statement should be transferred after interrupt");
}))
.withCauseInstanceOf(NoSuchElementException.class);
verify(statements).close();
} finally {
Thread.interrupted();
}
}

@Test
void transferStatementsKeepsNonInterruptNoSuchElementException() {
SailConnection connection = mock(SailConnection.class);
@SuppressWarnings("unchecked")
CloseableIteration<? extends Statement> statements = mock(CloseableIteration.class);
NoSuchElementException exception = new NoSuchElementException("empty");
doReturn(statements).when(connection).getStatements(isNull(), isNull(), isNull(), anyBoolean());
when(statements.hasNext()).thenReturn(true);
when(statements.next()).thenThrow(exception);

assertThatExceptionOfType(NoSuchElementException.class)
.isThrownBy(() -> ConnectionHelper.transferStatements(connection, (subject, predicate, object,
context) -> {
throw new AssertionError("No statement should be transferred");
}))
.isSameAs(exception);
verify(statements).close();
verify(statements, never()).remove();
}
}
12 changes: 6 additions & 6 deletions site/content/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ toc: true

You can either retrieve RDF4J via Apache Maven, or download the SDK or onejar directly.

## RDF4J 5.3.0 (latest)
## RDF4J 5.3.1 (latest)

RDF4J 5.3.0 is our latest stable release. It requires Java 11 minimally.
For details on what’s new and how to upgrade, see the [release and upgrade notes](/release-notes/5.3.0).
RDF4J 5.3.1 is our latest stable release. It requires Java 11 minimally.
For details on what’s new and how to upgrade, see the [release and upgrade notes](/release-notes/5.3.1).

- [RDF4J 5.3.0 SDK (zip)](http://www.eclipse.org/downloads/download.php?file=/rdf4j/eclipse-rdf4j-5.3.0-sdk.zip)<br/>
- [RDF4J 5.3.1 SDK (zip)](http://www.eclipse.org/downloads/download.php?file=/rdf4j/eclipse-rdf4j-5.3.1-sdk.zip)<br/>
Full Eclipse RDF4J SDK, containing all libraries, RDF4J Server, Workbench, and Console applications, and Javadoc API.

- [RDF4J 5.3.0 onejar](http://www.eclipse.org/downloads/download.php?file=/rdf4j/eclipse-rdf4j-5.3.0-onejar.jar)<br/>
- [RDF4J 5.3.1 onejar](http://www.eclipse.org/downloads/download.php?file=/rdf4j/eclipse-rdf4j-5.3.1-onejar.jar)<br/>
Single jar file for easy inclusion of the full RDF4J toolkit in your Java project.

- [RDF4J artifacts](https://search.maven.org/search?q=org.eclipse.rdf4j) on the [Maven Central Repository](http://search.maven.org/)
Expand All @@ -28,7 +28,7 @@ You can include RDF4J as a Maven dependency in your Java project by including th
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-bom</artifactId>
<version>5.3.0</version>
<version>5.3.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
14 changes: 14 additions & 0 deletions site/content/news/rdf4j-531.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "RDF4J 5.3.1 released"
date: 2026-04-23T21:24:25+0200
layout: "single"
categories: ["news"]
---
RDF4J 5.3.1 is now available. This is a patch release fixing 2 bugs.

For more details, have a look at the [release notes](/release-notes/5.3.1).
<!--more-->
### Links

- [Download RDF4J](/download/)
- [release notes](/release-notes/5.3.1)
11 changes: 11 additions & 0 deletions site/content/release-notes/5.3.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "5.3.1"
toc: true
---
RDF4J 5.3.1 is a patch release that fixes 2 performance issues.

For a complete overview, see [all issues fixed in 5.3.1](https://github.com/eclipse/rdf4j/milestone/129?closed=1).

### Acknowledgements

This release was made possible by contributions from [Håvard M. Ottestad](https://github.com/hmottestad).
Binary file added site/static/javadoc/5.3.1.tar.xz
Binary file not shown.
Binary file modified site/static/javadoc/latest.tar.xz
Binary file not shown.
Loading