Skip to content

Commit 27d775e

Browse files
committed
fixes
1 parent 73d1883 commit 27d775e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

core/http/client/src/main/java/org/eclipse/rdf4j/http/client/QueryCircuitBreakerHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ boolean requestCancel(QueryPressureState state, String reason) {
133133
cancellationReason = reason;
134134

135135
Thread activeWorker = workerThread;
136-
if (activeWorker != null) {
136+
if (activeWorker != null && activeWorker != Thread.currentThread()) {
137137
activeWorker.interrupt();
138138
}
139139

core/http/client/src/test/java/org/eclipse/rdf4j/http/client/QueryCircuitBreakerTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,22 @@ void shouldDisableHeavyOperatorExecutionOnlyWhileCritical() throws Exception {
117117
assertTrue(readHeavyOperatorExecutionEnabled());
118118
}
119119

120+
@Test
121+
void shouldNotLeaveCurrentThreadInterruptedWhenSelfCancelling() {
122+
QueryCircuitBreakerHandle handle = new QueryCircuitBreakerHandle("self-cancel",
123+
QueryCircuitBreakerHandle.Source.SERVER, "repo", "query", 0L, null);
124+
125+
try {
126+
handle.attach(Thread.currentThread(), null);
127+
128+
assertTrue(handle.requestCancel(QueryPressureState.CRITICAL, "self-cancel"));
129+
assertFalse(Thread.currentThread().isInterrupted());
130+
} finally {
131+
Thread.interrupted();
132+
handle.finish();
133+
}
134+
}
135+
120136
@Test
121137
void shouldIgnoreCheckpointStrideOnlyAtHighOrAbove() throws Exception {
122138
PropertiesScope properties = new PropertiesScope()

0 commit comments

Comments
 (0)