From 1fc8d6fbdfb3abd9b6fede0662f6c2efeb690f4b Mon Sep 17 00:00:00 2001 From: domkun <1139208+domkun@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:59:02 +0200 Subject: [PATCH] GH-4802: Fix setting isolation level in SailRepositoryConnection --- .../rdf4j/repository/sail/SailRepositoryConnection.java | 1 + .../repository/sail/SailRepositoryConnectionTest.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/core/repository/sail/src/main/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnection.java b/core/repository/sail/src/main/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnection.java index b53930ff72a..5290eb89211 100644 --- a/core/repository/sail/src/main/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnection.java +++ b/core/repository/sail/src/main/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnection.java @@ -167,6 +167,7 @@ public void begin() throws RepositoryException { @Override public void begin(IsolationLevel level) throws RepositoryException { + super.begin(level); try { // always call receiveTransactionSettings(...) before calling begin(); sailConnection.setTransactionSettings(new TransactionSetting[0]); diff --git a/core/repository/sail/src/test/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnectionTest.java b/core/repository/sail/src/test/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnectionTest.java index d0af7a12dd2..8353b88ec65 100644 --- a/core/repository/sail/src/test/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnectionTest.java +++ b/core/repository/sail/src/test/java/org/eclipse/rdf4j/repository/sail/SailRepositoryConnectionTest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.rdf4j.repository.sail; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; @@ -20,6 +21,7 @@ import java.util.Optional; import org.eclipse.rdf4j.common.iteration.EmptyIteration; +import org.eclipse.rdf4j.common.transaction.IsolationLevels; import org.eclipse.rdf4j.query.BooleanQuery; import org.eclipse.rdf4j.query.GraphQuery; import org.eclipse.rdf4j.query.Query; @@ -148,4 +150,11 @@ public void testPrepareBooleanQuery_bypassed() throws Exception { verify(sailConnection).evaluate(eq(expr), any(), any(), anyBoolean()); } + @Test + public void testIsolationLevelIsSet() throws Exception { + IsolationLevels isolationLevel = IsolationLevels.SERIALIZABLE; + subject.begin(isolationLevel); + assertThat(subject.getIsolationLevel()).isEqualTo(isolationLevel); + } + }