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

FIWARE / contract-management / #90

21 Apr 2026 02:35PM UTC coverage: 1.781%. First build
#90

push

Mortega5
add status code to request errors

2 of 5 new or added lines in 2 files covered. (40.0%)

623 of 34976 relevant lines covered (1.78%)

0.02 hits per line

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

0.0
/src/main/java/org/fiware/iam/http/AccessLogServerFilter.java
1
package org.fiware.iam.http;
2

3
import io.micronaut.context.annotation.ConfigurationProperties;
4
import io.micronaut.http.HttpRequest;
5
import io.micronaut.http.MutableHttpResponse;
6
import io.micronaut.http.annotation.Filter;
7
import io.micronaut.http.exceptions.HttpStatusException;
8
import io.micronaut.http.filter.HttpServerFilter;
9
import io.micronaut.http.filter.ServerFilterChain;
10
import jakarta.inject.Singleton;
11
import lombok.Data;
12
import lombok.RequiredArgsConstructor;
13
import lombok.extern.slf4j.Slf4j;
14
import org.reactivestreams.Publisher;
15
import reactor.core.publisher.Flux;
16

17
import java.util.List;
18

19
@Slf4j
×
20
@Filter("/**")
21
@RequiredArgsConstructor
22
public class AccessLogServerFilter implements HttpServerFilter {
23

24
    private final AccessLogConfiguration accessLogConfiguration;
25

26
    @Override
27
    public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) {
28
        if (accessLogConfiguration.getExcludePaths().stream().anyMatch(request.getUri().getPath()::startsWith)) {
×
29
            return chain.proceed(request);
×
30
        }
31

32
        long start = System.currentTimeMillis();
×
33

34
        return Flux.from(chain.proceed(request))
×
35
                .doOnNext(res -> {
×
36
                    long duration = System.currentTimeMillis() - start;
×
37
                    String remoteIp = request.getRemoteAddress().getAddress().getHostAddress();
×
38
                    String protocol = request.getHttpVersion().toString();
×
39
                    String method = request.getMethod().name();
×
40
                    String uri = request.getUri().toString();
×
41
                    int status = res.getStatus().getCode();
×
42
                    String forwardedFor = request.getHeaders().get("X-Forwarded-For");
×
43

44
                    if (forwardedFor != null) {
×
45
                        log.info("{} [{}] - {} - {} {} {} - {}ms", forwardedFor, remoteIp, protocol, method, uri, status, duration);
×
46
                    } else {
47
                        log.info("{} - {} - {} {} {} - {}ms", remoteIp, protocol, method, uri, status, duration);
×
48
                    }
49
                })
×
50
                .doOnError(e -> {
×
51
                    long duration = System.currentTimeMillis() - start;
×
52
                    String remoteIp = request.getRemoteAddress().getAddress().getHostAddress();
×
53
                    String forwardedFor = request.getHeaders().get("X-Forwarded-For");
×
NEW
54
                    String status = e instanceof HttpStatusException hse ? Integer.toString(hse.getStatus().getCode()) : "ERROR";
×
55

56
                    if (forwardedFor != null) {
×
NEW
57
                        log.error("{} [{}] - {} - {} {} {} - {}ms", forwardedFor, remoteIp, request.getHttpVersion(), request.getMethod(), request.getUri(), status, duration, e);
×
58
                    } else {
NEW
59
                        log.error("{} - {} - {} {} {} - {}ms", remoteIp, request.getHttpVersion(), request.getMethod(), request.getUri(), status, duration, e);
×
60
                    }
61
                });
×
62
    }
63

64
    @Data
65
    @Singleton
66
    @ConfigurationProperties("http.server.log")
67
    public static class AccessLogConfiguration {
68
        private List<String> excludePaths = List.of();
69
    }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc