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

wz2cool / local-queue / #98

06 Jul 2025 03:07PM UTC coverage: 91.329% (+0.5%) from 90.82%
#98

Pull #18

wz2cool
fix deployment
Pull Request #18: Support headers new

148 of 150 new or added lines in 6 files covered. (98.67%)

811 of 888 relevant lines covered (91.33%)

0.91 hits per line

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

92.86
/src/main/java/com/github/wz2cool/localqueue/model/message/internal/HeaderMessage.java
1
package com.github.wz2cool.localqueue.model.message.internal;
2

3
import net.openhft.chronicle.bytes.BytesIn;
4
import net.openhft.chronicle.bytes.BytesMarshallable;
5
import net.openhft.chronicle.bytes.BytesOut;
6
import net.openhft.chronicle.core.io.IORuntimeException;
7
import net.openhft.chronicle.core.io.InvalidMarshallableException;
8

9
import java.nio.BufferOverflowException;
10
import java.nio.BufferUnderflowException;
11
import java.util.*;
12

13
public class HeaderMessage implements BytesMarshallable {
14

15
    private Map<String, String> headers;
16

17
    public HeaderMessage(Map<String, String> headers) {
1✔
18
        this.headers = headers;
1✔
19
    }
1✔
20

21
    public Optional<String> getHeaderValue(String headerKey) {
22
        if (Objects.isNull(headers)) {
1✔
NEW
23
            return Optional.empty();
×
24
        }
25
        return Optional.ofNullable(headers.get(headerKey));
1✔
26
    }
27

28
    public Set<String> getHeaderKeys() {
29
        if (Objects.isNull(headers)) {
1✔
NEW
30
            return new HashSet<>();
×
31
        }
32
        return headers.keySet();
1✔
33
    }
34

35
    @Override
36
    public void readMarshallable(BytesIn<?> bytes) throws IORuntimeException, BufferUnderflowException, IllegalStateException, InvalidMarshallableException {
37
        int mapSize = bytes.readInt();
1✔
38
        if (mapSize > 0) {
1✔
39
            if (Objects.isNull(headers)) {
1✔
40
                headers = new HashMap<>(mapSize);
1✔
41
            }
42
            for (int i = 0; i < mapSize; i++) {
1✔
43
                String key = bytes.readUtf8();
1✔
44
                String value = bytes.readUtf8();
1✔
45
                if (Objects.nonNull(key)) {
1✔
46
                    headers.put(key, value);
1✔
47
                }
48
            }
49
        }
50
    }
1✔
51

52
    @Override
53
    public void writeMarshallable(BytesOut<?> bytes) throws IllegalStateException, BufferOverflowException, BufferUnderflowException, ArithmeticException, InvalidMarshallableException {
54
        if (Objects.isNull(headers)) {
1✔
55
            bytes.writeInt(0);
1✔
56
            return;
1✔
57
        }
58
        bytes.writeInt(headers.size());
1✔
59
        for (Map.Entry<String, String> entry : headers.entrySet()) {
1✔
60
            bytes.writeUtf8(entry.getKey());
1✔
61
            bytes.writeUtf8(entry.getValue());
1✔
62
        }
1✔
63
    }
1✔
64
}
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