Skip to content

Commit 3850623

Browse files
committed
mostly functional
1 parent d403511 commit 3850623

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbTxnContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ ChangeView snapshotChanges(boolean explicit) {
457457

458458
Set<Quad> snapshotDeprecated(boolean explicit) {
459459
Set<Quad> deprecated = new LinkedHashSet<>(explicit ? deprecatedExplicit : deprecatedInferred);
460+
applyPendingDeprecatedTo(deprecated, explicit);
460461
return deprecated;
461462
}
462463

testsuites/sail/src/main/java/org/eclipse/rdf4j/testsuite/sail/SailConcurrencyTest.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static org.junit.jupiter.api.Assertions.assertEquals;
1515
import static org.junit.jupiter.api.Assertions.assertNotNull;
1616

17+
import java.util.Locale;
1718
import java.util.Random;
1819
import java.util.concurrent.CountDownLatch;
1920
import java.util.concurrent.TimeUnit;
@@ -39,6 +40,10 @@
3940
import org.junit.jupiter.api.RepeatedTest;
4041
import org.junit.jupiter.api.Test;
4142
import org.junit.jupiter.api.Timeout;
43+
import org.junit.jupiter.api.extension.BeforeEachCallback;
44+
import org.junit.jupiter.api.extension.ExtensionContext;
45+
import org.junit.jupiter.api.extension.RegisterExtension;
46+
import org.junit.jupiter.api.extension.TestWatcher;
4247
import org.slf4j.Logger;
4348
import org.slf4j.LoggerFactory;
4449

@@ -50,6 +55,10 @@
5055
public abstract class SailConcurrencyTest {
5156

5257
private static final Logger logger = LoggerFactory.getLogger(SailConcurrencyTest.class);
58+
private static final String TIMED_OUT_KEY = "timedOutTest";
59+
60+
@RegisterExtension
61+
static final TimeoutClassFailureWatcher TIMEOUT_CLASS_FAILURE_WATCHER = new TimeoutClassFailureWatcher();
5362
/*-----------*
5463
* Constants *
5564
*-----------*/
@@ -90,6 +99,49 @@ public void tearDown() {
9099
store.shutDown();
91100
}
92101

102+
private static final class TimeoutClassFailureWatcher implements TestWatcher, BeforeEachCallback {
103+
104+
@Override
105+
public void beforeEach(ExtensionContext context) {
106+
AtomicReference<String> timedOut = getTimedOutRef(context);
107+
String timedOutTest = timedOut.get();
108+
if (timedOutTest != null) {
109+
Assertions.fail("Previous test timed out (" + timedOutTest + "); failing remaining tests in class");
110+
}
111+
}
112+
113+
@Override
114+
public void testFailed(ExtensionContext context, Throwable cause) {
115+
if (isTimeout(cause)) {
116+
getTimedOutRef(context).compareAndSet(null, context.getDisplayName());
117+
}
118+
}
119+
120+
private static AtomicReference<String> getTimedOutRef(ExtensionContext context) {
121+
ExtensionContext.Namespace namespace = ExtensionContext.Namespace.create(SailConcurrencyTest.class,
122+
context.getRequiredTestClass());
123+
return context.getStore(namespace)
124+
.getOrComputeIfAbsent(TIMED_OUT_KEY, key -> new AtomicReference<String>(),
125+
AtomicReference.class);
126+
}
127+
128+
private static boolean isTimeout(Throwable cause) {
129+
Throwable current = cause;
130+
while (current != null) {
131+
if (current instanceof java.util.concurrent.TimeoutException
132+
|| "org.junit.jupiter.api.TimeoutException".equals(current.getClass().getName())) {
133+
return true;
134+
}
135+
String message = current.getMessage();
136+
if (message != null && message.toLowerCase(Locale.ROOT).contains("timed out")) {
137+
return true;
138+
}
139+
current = current.getCause();
140+
}
141+
return false;
142+
}
143+
}
144+
93145
protected class UploadTransaction implements Runnable {
94146

95147
private final IRI context;

0 commit comments

Comments
 (0)