• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eXist-db / exist / 41019023168

30 Oct 2026 07:15AM UTC coverage: 58.191% (+0.002%) from 58.189%
41019023168

push

github

web-flow
Merge pull request #6951 from eXist-db/dependabot/maven/maven-plugins-tools-9d8b030d75

Bump org.jacoco:jacoco-maven-plugin from 0.8.15 to 0.8.16 in the maven-plugins-tools group

32497 of 61720 branches covered (52.65%)

Branch coverage included in aggregate %.

85590 of 141211 relevant lines covered (60.61%)

2.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/exist-core/src/main/java/org/exist/http/ws/EvalSession.java
1
/*
2
 * eXist-db Open Source Native XML Database
3
 * Copyright (C) 2001 The eXist-db Authors
4
 *
5
 * info@exist-db.org
6
 * http://www.exist-db.org
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
 */
22
package org.exist.http.ws;
23

24
import org.exist.security.Subject;
25
import org.exist.xquery.XQueryWatchDog;
26

27
import javax.annotation.Nullable;
28
import java.util.Map;
29
import java.util.concurrent.ConcurrentHashMap;
30

31
/**
32
 * Per-connection state for the /ws/eval WebSocket endpoint.
33
 *
34
 * Tracks the authenticated user and all running queries for cancellation.
35
 */
36
public final class EvalSession {
37

38
    private final Subject subject;
39
    private final Map<String, XQueryWatchDog> runningQueries = new ConcurrentHashMap<>();
5 ✔
40

41
    public EvalSession(final Subject subject) {
2 ✔
42
        this.subject = subject;
3 ✔
43
    }
1 ✔
44

45
    public Subject getSubject() {
46
        return subject;
3 ✔
47
    }
48

49
    /**
50
     * Register a running query's watchdog for cancellation.
51
     */
52
    public void registerQuery(final String queryId, final XQueryWatchDog watchDog) {
53
        runningQueries.put(queryId, watchDog);
6 ✔
54
    }
1 ✔
55

56
    /**
57
     * Unregister a completed or cancelled query.
58
     */
59
    public void unregisterQuery(final String queryId) {
60
        runningQueries.remove(queryId);
5 ✔
61
    }
1 ✔
62

63
    /**
64
     * Cancel a running query by its ID.
65
     *
66
     * @return true if the query was found and cancelled
67
     */
68
    public boolean cancelQuery(final String queryId) {
69
        final XQueryWatchDog watchDog = runningQueries.get(queryId);
6 ✔
70
        if (watchDog != null) {
2 !
71
            watchDog.kill(0);
3 ✔
72
            return true;
2 ✔
73
        }
74
        return false;
×
75
    }
76

77
    /**
78
     * Cancel all running queries (called on session close).
79
     */
80
    public void cancelAll() {
81
        for (final XQueryWatchDog watchDog : runningQueries.values()) {
13 ✔
82
            watchDog.kill(0);
3 ✔
83
        }
84
        runningQueries.clear();
3 ✔
85
    }
1 ✔
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc