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

nats-io / nats.java / #2020

29 Jun 2025 06:09PM UTC coverage: 95.643% (+0.05%) from 95.598%
#2020

push

github

web-flow
Merge pull request #1335 from nats-io/replace-timer

Replace Timer with scheduled tasks

66 of 77 new or added lines in 6 files covered. (85.71%)

1 existing line in 1 file now uncovered.

11767 of 12303 relevant lines covered (95.64%)

0.96 hits per line

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

50.0
/src/main/java/io/nats/client/NatsSystemClock.java
1
// Copyright 2025 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;
15

NEW
16
public final class NatsSystemClock {
×
17
    private static NatsSystemClockProvider PROVIDER = new NatsSystemClockProvider() {};
1✔
18

19
    /**
20
     * Set the provider. Null will reset to system default
21
     * @param provider the provider
22
     */
23
    public static void setProvider(final NatsSystemClockProvider provider) {
24
        PROVIDER = provider == null ? new NatsSystemClockProvider() {} : provider;
×
25
    }
×
26

27
    /**
28
     * Get the current milliseconds from the provider
29
     * @return the milliseconds
30
     */
31
    public static long currentTimeMillis() {
32
        return PROVIDER.currentTimeMillis();
1✔
33
    }
34

35
    /**
36
     * Get the current nano time from the provider
37
     * @return the nano time
38
     */
39
    public static long nanoTime() {
40
        return PROVIDER.nanoTime();
1✔
41
    }
42
}
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