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

zalando / logbook / 5242

09 Jan 2026 05:56PM UTC coverage: 98.199% (-1.8%) from 100.0%
5242

push

github

web-flow
Fix coveral on main builds (#2201)

* Switch to com.github.hazendaz.maven:coveralls-maven-plugin as org.eluder.coveralls is deprecated

* tmp allow coveral on PRs

* revert the tmp allow coveral on PRs

* use ${project.artifactId} instaed of ${artifactId} in pom.xml

754 of 768 branches covered (98.18%)

3871 of 3942 relevant lines covered (98.2%)

0.98 hits per line

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

78.57
/logbook-json/src/main/java/org/zalando/logbook/json/CompactingJsonBodyFilter.java
1
package org.zalando.logbook.json;
2

3
import lombok.AllArgsConstructor;
4
import lombok.Generated;
5
import lombok.extern.slf4j.Slf4j;
6
import org.apiguardian.api.API;
7
import org.zalando.logbook.BodyFilter;
8
import org.zalando.logbook.ContentType;
9

10
import jakarta.annotation.Nullable;
11
import java.io.IOException;
12

13
import static org.apiguardian.api.API.Status.MAINTAINED;
14

15
/**
16
 * @see FastCompactingJsonBodyFilter
17
 */
18
@API(status = MAINTAINED)
19
@Slf4j
1✔
20
@AllArgsConstructor
21
public final class CompactingJsonBodyFilter implements BodyFilter {
22

23
    private final JsonCompactor compactor;
24

25
    public CompactingJsonBodyFilter(final JsonGeneratorWrapperJackson2 jsonGeneratorWrapperJackson2) {
26
        this(new ParsingJsonCompactorJackson2(jsonGeneratorWrapperJackson2));
1✔
27
    }
1✔
28

29
    public CompactingJsonBodyFilter(final JsonGeneratorWrapper jsonGeneratorWrapper) {
30
        this(new ParsingJsonCompactor(jsonGeneratorWrapper));
1✔
31
    }
1✔
32

33
    @Generated
34
    public CompactingJsonBodyFilter() {
35
        this(createDefaultCompactor());
36
    }
37

38
    @lombok.Generated
39
    private static JsonCompactor createDefaultCompactor() {
40
        try {
41
            // Try Jackson 3 first when explicitly requested
42
            Class.forName("tools.jackson.core.json.JsonFactory");
43
            return new ParsingJsonCompactor();
44
        } catch (final ClassNotFoundException e) {
45
            return new ParsingJsonCompactorJackson2();
46
        }
47
    }
48

49
    @Override
50
    public String filter(@Nullable final String contentType, final String body) {
51
        if (!ContentType.isJsonMediaType(contentType)) {
1✔
52
            return body;
1✔
53
        }
54

55
        try {
56
            return compactor.compact(body);
1✔
57
        } catch (final IOException e) {
×
58
            log.trace("Unable to compact body, is it a JSON?. Keep it as-is: `{}`", e.getMessage());
×
59
            return body;
×
60
        } catch (final RuntimeException e) {
1✔
61
            // Handle Jackson parsing errors (both Jackson 2 and 3)
62
            // Note: This catch is for Jackson 3 which throws RuntimeExceptions instead of IOExceptions
63
            log.trace("Unable to compact body, is it a JSON?. Keep it as-is: `{}`", e.getMessage());
1✔
64
            return body;
1✔
65
        }
66
    }
67

68
}
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