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

FIWARE / contract-management / #116

04 Nov 2026 06:22AM UTC coverage: 7.885% (+3.4%) from 4.488%
#116

Pull #31

wistefan
Address the review comments of PR #31

* OID4VP flows triggered by a participant-chosen sink use their own non-redirecting client
* a reached subscription cap is refused with 503 instead of 409, which a subscriber reads as an existing subscription
* document the broadcast semantics of subscriptions in the security notes
Pull Request #31: subscriptions, webhook handshake and delivery

1035 of 1054 new or added lines in 36 files covered. (98.2%)

2927 of 37120 relevant lines covered (7.89%)

0.08 hits per line

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

91.3
/src/main/java/org/fiware/iam/dataspace/ConfigFileRefresher.java
1
package org.fiware.iam.dataspace;
2

3
import io.micronaut.context.annotation.Requires;
4
import io.micronaut.context.env.Environment;
5
import io.micronaut.context.event.ApplicationEventListener;
6
import io.micronaut.context.event.ApplicationEventPublisher;
7
import io.micronaut.runtime.context.scope.refresh.RefreshEvent;
8
import io.micronaut.scheduling.TaskExecutors;
9
import io.micronaut.scheduling.TaskScheduler;
10
import io.micronaut.scheduling.io.watch.event.FileChangedEvent;
11
import jakarta.inject.Named;
12
import jakarta.inject.Singleton;
13
import lombok.extern.slf4j.Slf4j;
14
import org.fiware.iam.configuration.DataSpaceEventsProperties;
15

16
import java.time.Duration;
17
import java.util.Map;
18
import java.util.concurrent.ScheduledFuture;
19

20
/**
21
 * Refreshes the configuration when the watched directory changes, like a POST to /refresh does.
22
 * Reacts to any change below the watched path: a ConfigMap update swaps the ..data symlink, never the config file itself.
23
 */
24
@Slf4j
1 ✔
25
@Singleton
26
@Requires(condition = DataSpaceEventsProperties.WatchCondition.class)
27
public class ConfigFileRefresher implements ApplicationEventListener<FileChangedEvent> {
28

29
    /**
30
     * Quiet period after the last file event before refreshing; one ConfigMap update emits several events.
31
     */
32
    static final Duration DEBOUNCE = Duration.ofMillis(500);
1 ✔
33

34
    private final Environment environment;
35
    private final ApplicationEventPublisher<RefreshEvent> refreshPublisher;
36
    private final TaskScheduler scheduler;
37
    private final ConfigurationRefreshLock refreshLock;
38
    private ScheduledFuture<?> pending;
39

40
    public ConfigFileRefresher(Environment environment, ApplicationEventPublisher<RefreshEvent> refreshPublisher,
41
                               @Named(TaskExecutors.SCHEDULED) TaskScheduler scheduler, ConfigurationRefreshLock refreshLock) {
1 ✔
42
        this.environment = environment;
1 ✔
43
        this.refreshPublisher = refreshPublisher;
1 ✔
44
        this.scheduler = scheduler;
1 ✔
45
        this.refreshLock = refreshLock;
1 ✔
46
    }
1 ✔
47

48
    @Override
49
    public synchronized void onApplicationEvent(FileChangedEvent event) {
50
        log.debug("Configuration path {} changed ({}).", event.getPath(), event.getEventType());
1 ✔
51
        if (pending != null) {
1 ✔
52
            pending.cancel(false);
1 ✔
53
        }
54
        pending = scheduler.schedule(DEBOUNCE, this::refresh);
1 ✔
55
    }
1 ✔
56

57
    void refresh() {
58
        try {
59
            refreshLock.exclusively(this::refreshAndPublish);
1 ✔
NEW
60
        } catch (RuntimeException e) {
×
NEW
61
            log.warn("Refreshing the configuration after a file change failed.", e);
×
62
        }
1 ✔
63
    }
1 ✔
64

65
    private Map<String, Object> refreshAndPublish() {
66
        // refreshAndDiff re-reads the property sources; a bare RefreshEvent would rebind from the stale environment
67
        Map<String, Object> diff = environment.refreshAndDiff();
1 ✔
68
        if (!diff.isEmpty()) {
1 ✔
69
            log.info("Configuration file changed, refreshing keys {}.", diff.keySet());
1 ✔
70
            refreshPublisher.publishEvent(new RefreshEvent(diff));
1 ✔
71
        }
72
        return diff;
1 ✔
73
    }
74
}
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