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

eXist-db / exist / 40387836984

26 Oct 2026 07:33PM UTC coverage: 58.173% (+0.005%) from 58.168%
40387836984

push

github

web-flow
Merge pull request #6731 from line-o/bugfix/binary-value-frame-ownership

[bugfix] Release a binary value with the scope that created it

32491 of 61752 branches covered (52.62%)

Branch coverage included in aggregate %.

92 of 129 new or added lines in 8 files covered. (71.32%)

27 existing lines in 6 files now uncovered.

85598 of 141244 relevant lines covered (60.6%)

2.73 hits per line

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

55.0
/exist-core/src/main/java/org/exist/util/io/FilterInputStreamCacheMonitor.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

23
package org.exist.util.io;
24

25
import java.util.*;
26
import java.util.concurrent.ConcurrentHashMap;
27
import java.util.concurrent.ConcurrentMap;
28

29
/**
30
 * Monitors active {@link FilterInputStreamCacheMonitor} instances.
31
 *
32
 * @author <a href="mailto:adam.retter@googlemail.com">Adam Retter</a>
33
 */
34
public class FilterInputStreamCacheMonitor {
35

36
    private static final FilterInputStreamCacheMonitor INSTANCE = new FilterInputStreamCacheMonitor();
5 ✔
37

38
    private final ConcurrentMap<FilterInputStreamCache, FilterInputStreamCacheInfo> activeCaches = new ConcurrentHashMap<>();
5 ✔
39

40
    private FilterInputStreamCacheMonitor() {
2 ✔
41
    }
1 ✔
42

43
    public static FilterInputStreamCacheMonitor getInstance() {
44
        return INSTANCE;
2 ✔
45
    }
46

47
    /**
48
     * Intentionally package private!
49
     * 
50
     * Only for use by org.exist.util.io.FilterInputStreamCacheMonitorTest
51
     */
52
    void clear() {
53
        activeCaches.clear();
3 ✔
54
    }
1 ✔
55

56
    public void register(final FilterInputStreamCache cache) {
57
        final long now = System.currentTimeMillis();
2 ✔
58
        final FilterInputStreamCacheInfo info = new FilterInputStreamCacheInfo(now, cache);
6 ✔
59
        activeCaches.put(cache, info);
6 ✔
60
    }
1 ✔
61

62
    public Collection<FilterInputStreamCacheInfo> getActive() {
63
        final List<FilterInputStreamCacheInfo> list = new ArrayList(activeCaches.values());
7 ✔
64
        list.sort(Comparator.comparingLong(FilterInputStreamCacheInfo::getRegistered));
4 ✔
65
        return list;
2 ✔
66
    }
67

68
    public void deregister(final FilterInputStreamCache cache) {
69
        activeCaches.remove(cache);
5 ✔
70
    }
1 ✔
71

72
    public String dump() {
UNCOV
73
        final StringBuilder builder = new StringBuilder();
×
UNCOV
74
        for (final FilterInputStreamCacheInfo info : getActive()) {
×
UNCOV
75
            final FilterInputStreamCache cache = info.getCache();
×
UNCOV
76
            final String id = switch (cache) {
×
UNCOV
77
                case FileFilterInputStreamCache fileFilterInputStreamCache ->
×
UNCOV
78
                        fileFilterInputStreamCache.getFilePath().normalize().toAbsolutePath().toString();
×
79
                case MemoryMappedFileFilterInputStreamCache memoryMappedFileFilterInputStreamCache ->
×
80
                        memoryMappedFileFilterInputStreamCache.getFilePath().normalize().toAbsolutePath().toString();
×
81
                case MemoryFilterInputStreamCache memoryFilterInputStreamCache -> "mem";
×
82
                case null, default -> "unknown";
×
83
            };
UNCOV
84
            builder.append(info.getRegistered()).append(": ").append(id);
×
85
        }
UNCOV
86
        return builder.toString();
×
87
    }
88

89
    public static class FilterInputStreamCacheInfo {
90
        private final long registered;
91
        private final FilterInputStreamCache cache;
92

93
        public FilterInputStreamCacheInfo(final long registered, final FilterInputStreamCache cache) {
2 ✔
94
            this.registered = registered;
3 ✔
95
            this.cache = cache;
3 ✔
96
        }
1 ✔
97

98
        public long getRegistered() {
99
            return registered;
3 ✔
100
        }
101

102
        public FilterInputStreamCache getCache() {
103
            return cache;
3 ✔
104
        }
105
    }
106
}
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