• 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

0.0
/src/main/java/io/nats/client/impl/DataPort.java
1
// Copyright 2015-2018 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.Options;
17
import io.nats.client.support.NatsUri;
18
import org.jspecify.annotations.NonNull;
19

20
import java.io.IOException;
21

22
/**
23
 * A data port represents the connection to the network. This could have been called
24
 * transport but that seemed too big a concept. This interface just allows a wrapper around
25
 * the core communication code.
26
 */
27
public interface DataPort {
28
    void connect(@NonNull String serverURI, @NonNull NatsConnection conn, long timeoutNanos) throws IOException;
29

30
    default void connect(@NonNull NatsConnection conn, @NonNull NatsUri uri, long timeoutNanos) throws IOException {
31
        connect(uri.toString(), conn, timeoutNanos);
×
UNCOV
32
    }
×
33

UNCOV
34
    default void afterConstruct(Options options) {}
×
35

36
    /**
37
     * Upgrade the port to SSL. If it is already secured, this is a no-op.
38
     * If the data port type doesn't support SSL it should throw an exception.
39
     *
40
     * @throws IOException if the data port is unable to upgrade.
41
     */
42
    void upgradeToSecure() throws IOException;
43

44
    int read(byte[] dst, int off, int len) throws IOException;
45

46
    /**
47
     * NOTE: the buffer will be modified if communicating over websockets and
48
     * the toWrite is greater than 1432.
49
     * 
50
     * @param src output byte[]
51
     * @param toWrite number of bytes to write
52
     * @throws IOException any IO error on the underlaying connection
53
     */
54
    void write(byte[] src, int toWrite) throws IOException;
55

56
    void shutdownInput() throws IOException;
57

58
    void close() throws IOException;
59

60
    default void forceClose() throws IOException {
61
        close();
×
UNCOV
62
    }
×
63

64
    void flush() throws IOException;
65
}
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