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

nats-io / nats.java / #2101

12 Aug 2025 11:26AM UTC coverage: 95.457% (+0.02%) from 95.433%
#2101

push

github

web-flow
Merge pull request #1387 from nats-io/info-nullability

Ensuring nullability contracts

92 of 92 new or added lines in 10 files covered. (100.0%)

108 existing lines in 12 files now uncovered.

11913 of 12480 relevant lines covered (95.46%)

0.95 hits per line

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

81.25
/src/main/java/io/nats/client/impl/NatsOrderedConsumerContext.java
1
// Copyright 2020-2023 The NATS Authors
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at:
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13

14
package io.nats.client.impl;
15

16
import io.nats.client.*;
17
import io.nats.client.api.OrderedConsumerConfiguration;
18
import org.jspecify.annotations.NonNull;
19
import org.jspecify.annotations.Nullable;
20

21
import java.io.IOException;
22
import java.time.Duration;
23

24
/**
25
 * Implementation of Ordered Consumer Context
26
 */
27
public class NatsOrderedConsumerContext implements OrderedConsumerContext {
28
    private final NatsConsumerContext impl;
29

30
    NatsOrderedConsumerContext(@NonNull NatsStreamContext streamContext,
31
                               @NonNull OrderedConsumerConfiguration config) {
1✔
32
        impl = new NatsConsumerContext(streamContext, null, config);
1✔
33
    }
1✔
34

35
    /**
36
     * Gets the consumer name created for the underlying Ordered Consumer
37
     * This will return null until the first consume (next, iterate, fetch, consume)
38
     * is executed because the JetStream consumer, which carries the name,
39
     * has not been created yet.
40
     * <p>
41
     * The consumer name is subject to change for 2 reasons.
42
     * 1. Any time next(...) is called
43
     * 2. Anytime a message is received out of order for instance because of a disconnection
44
     * </p>
45
     * <p>If your OrderedConsumerConfiguration has a consumerNamePrefix,
46
     * the consumer name will always start with the prefix
47
     * </p>
48
     * @return the consumer name or null
49
     */
50
    @Override
51
    public String getConsumerName() {
52
        return impl.getConsumerName();
1✔
53
    }
54

55
    /**
56
     * {@inheritDoc}
57
     */
58
    @Override
59
    @Nullable
60
    public Message next() throws IOException, InterruptedException, JetStreamStatusCheckedException, JetStreamApiException {
61
        return impl.next();
1✔
62
    }
63

64
    /**
65
     * {@inheritDoc}
66
     */
67
    @Override
68
    @Nullable
69
    public Message next(@Nullable Duration maxWait) throws IOException, InterruptedException, JetStreamStatusCheckedException, JetStreamApiException {
70
        return impl.next(maxWait);
1✔
71
    }
72

73
    /**
74
     * {@inheritDoc}
75
     */
76
    @Override
77
    @Nullable
78
    public Message next(long maxWaitMillis) throws IOException, InterruptedException, JetStreamStatusCheckedException, JetStreamApiException {
79
        return impl.next(maxWaitMillis);
1✔
80
    }
81

82
    /**
83
     * {@inheritDoc}
84
     */
85
    @Override
86
    @NonNull
87
    public FetchConsumer fetchMessages(int maxMessages) throws IOException, JetStreamApiException {
88
        return impl.fetchMessages(maxMessages);
1✔
89
    }
90

91
    /**
92
     * {@inheritDoc}
93
     */
94
    @Override
95
    @NonNull
96
    public FetchConsumer fetchBytes(int maxBytes) throws IOException, JetStreamApiException {
UNCOV
97
        return impl.fetchBytes(maxBytes);
×
98
    }
99

100
    /**
101
     * {@inheritDoc}
102
     */
103
    @Override
104
    @NonNull
105
    public FetchConsumer fetch(@NonNull FetchConsumeOptions fetchConsumeOptions) throws IOException, JetStreamApiException {
106
        return impl.fetch(fetchConsumeOptions);
1✔
107
    }
108

109
    /**
110
     * {@inheritDoc}
111
     */
112
    @Override
113
    @NonNull
114
    public IterableConsumer iterate() throws IOException, JetStreamApiException {
115
        return impl.iterate();
1✔
116
    }
117

118
    /**
119
     * {@inheritDoc}
120
     */
121
    @Override
122
    @NonNull
123
    public IterableConsumer iterate(@NonNull ConsumeOptions consumeOptions) throws IOException, JetStreamApiException {
124
        return impl.iterate(consumeOptions);
1✔
125
    }
126

127
    /**
128
     * {@inheritDoc}
129
     */
130
    @Override
131
    @NonNull
132
    public MessageConsumer consume(@NonNull MessageHandler handler) throws IOException, JetStreamApiException {
133
        return impl.consume(handler);
1✔
134
    }
135

136
    /**
137
     * {@inheritDoc}
138
     */
139
    @Override
140
    @NonNull
141
    public MessageConsumer consume(@Nullable Dispatcher dispatcher, @NonNull MessageHandler handler) throws IOException, JetStreamApiException {
UNCOV
142
        return impl.consume(dispatcher, handler);
×
143
    }
144

145
    /**
146
     * {@inheritDoc}
147
     */
148
    @Override
149
    @NonNull
150
    public MessageConsumer consume(@NonNull ConsumeOptions consumeOptions, @NonNull MessageHandler handler) throws IOException, JetStreamApiException {
151
        return impl.consume(consumeOptions, handler);
1✔
152
    }
153

154
    /**
155
     * {@inheritDoc}
156
     */
157
    @Override
158
    @NonNull
159
    public MessageConsumer consume(@NonNull ConsumeOptions consumeOptions, @Nullable Dispatcher dispatcher, @NonNull MessageHandler handler) throws IOException, JetStreamApiException {
UNCOV
160
        return impl.consume(consumeOptions, dispatcher, handler);
×
161
    }
162
}
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