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

wz2cool / local-queue / #82

06 Feb 2025 03:31PM UTC coverage: 91.284% (-0.3%) from 91.534%
#82

push

wz2cool
support headers

68 of 70 new or added lines in 5 files covered. (97.14%)

3 existing lines in 1 file now uncovered.

775 of 849 relevant lines covered (91.28%)

0.91 hits per line

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

94.74
/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.HashMap;
12
import java.util.Map;
13
import java.util.Optional;
14
import java.util.Set;
15

16
public class HeaderMessage implements BytesMarshallable {
1✔
17

18
    private final Map<String, String> headers = new HashMap<>();
1✔
19

20
    public synchronized void putHeader(String key, String value) {
21
        headers.put(key, value);
1✔
22
    }
1✔
23

24
    public synchronized Optional<String> getHeader(String key) {
25
        return Optional.ofNullable(headers.get(key));
1✔
26
    }
27

28
    public synchronized Set<String> getHeaderKeys() {
NEW
29
        return headers.keySet();
×
30
    }
31

32
    @Override
33
    public void readMarshallable(BytesIn<?> bytes) throws IORuntimeException, BufferUnderflowException, IllegalStateException, InvalidMarshallableException {
34
        int mapSize = bytes.readInt();
1✔
35
        if (mapSize > 0) {
1✔
36
            for (int i = 0; i < mapSize; i++) {
1✔
37
                String key = bytes.readUtf8();
1✔
38
                String value = bytes.readUtf8();
1✔
39
                headers.put(key, value);
1✔
40
            }
41
        }
42
    }
1✔
43

44
    @Override
45
    public void writeMarshallable(BytesOut<?> bytes) throws IllegalStateException, BufferOverflowException, BufferUnderflowException, ArithmeticException, InvalidMarshallableException {
46
        bytes.writeInt(headers.size());
1✔
47
        for (Map.Entry<String, String> entry : headers.entrySet()) {
1✔
48
            bytes.writeUtf8(entry.getKey());
1✔
49
            bytes.writeUtf8(entry.getValue());
1✔
50
        }
1✔
51
    }
1✔
52
}
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