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

sonus21 / rqueue / 2767

02 Jul 2024 07:12PM UTC coverage: 91.424% (-0.03%) from 91.458%
2767

push

circleci

web-flow
Bump nokogiri from 1.16.2 to 1.16.5 in /docs (#226)

Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.16.2 to 1.16.5.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.16.2...v1.16.5)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

5373 of 5877 relevant lines covered (91.42%)

0.91 hits per line

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

64.29
/rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/TimeoutUtils.java
1
/*
2
 * Copyright (c) 2020-2023 Sonu Kumar
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * You may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and limitations under the License.
14
 *
15
 */
16

17
package com.github.sonus21.rqueue.utils;
18

19
import com.github.sonus21.rqueue.exception.TimedOutException;
20
import java.util.function.BooleanSupplier;
21

22
/**
23
 * waitFor method wait for some event to occur. It accepts a callback as well that can be invoked on
24
 * successive failure of the method. That can be used to diagnosis the test. A callback method is
25
 * used to identify the outcome of some event, if the specified method returns true then call is
26
 * stopped otherwise every 100Ms the callback would be called to get the outcome. It tries for
27
 * continuously over 10seconds If callback does not return true within 10 seconds then it will throw
28
 * TimeOutException. If postmortem method is provided then it will call that method before throwing
29
 * exception.
30
 */
31
public final class TimeoutUtils {
32

33
  public static final long EXECUTION_TIME = 10_000L;
34
  public static final long SLEEP_TIME = 100L;
35

36
  private TimeoutUtils() {
37
  }
38

39
  public static void waitFor(
40
      BooleanSupplier callback, long waitTimeInMilliSeconds, String description)
41
      throws TimedOutException {
42
    waitFor(callback, waitTimeInMilliSeconds, SLEEP_TIME, description, () -> {
1✔
43
    });
×
44
  }
1✔
45

46
  public static void waitFor(BooleanSupplier callback, String description)
47
      throws TimedOutException {
48
    waitFor(callback, EXECUTION_TIME, description);
1✔
49
  }
1✔
50

51
  public static void waitFor(BooleanSupplier callback, String description, Runnable postmortem)
52
      throws TimedOutException {
53
    waitFor(callback, EXECUTION_TIME, SLEEP_TIME, description, postmortem);
1✔
54
  }
1✔
55

56
  public static void waitFor(
57
      BooleanSupplier callback,
58
      long waitTimeInMilliSeconds,
59
      String description,
60
      Runnable postmortem)
61
      throws TimedOutException {
62
    waitFor(callback, waitTimeInMilliSeconds, SLEEP_TIME, description, postmortem);
1✔
63
  }
1✔
64

65
  public static void waitFor(
66
      BooleanSupplier callback,
67
      long waitTimeInMilliSeconds,
68
      long sleepDuration,
69
      String description,
70
      Runnable postmortem)
71
      throws TimedOutException {
72
    long endTime = System.currentTimeMillis() + waitTimeInMilliSeconds;
1✔
73
    do {
74
      if (Boolean.TRUE.equals(callback.getAsBoolean())) {
1✔
75
        return;
1✔
76
      }
77
      sleep(sleepDuration);
1✔
78
    } while (System.currentTimeMillis() < endTime);
1✔
79
    try {
80
      postmortem.run();
×
81
    } catch (Exception e) {
×
82
      e.printStackTrace();
×
83
    }
×
84
    throw new TimedOutException("Timed out waiting for " + description);
×
85
  }
86

87
  public static void sleep(long time) {
88
    sleepLog(time, true);
1✔
89
  }
1✔
90

91
  public static void sleepLog(long time, boolean log) {
92
    try {
93
      Thread.sleep(time);
1✔
94
    } catch (InterruptedException e) {
×
95
      Thread.currentThread().interrupt();
×
96
      if (log) {
×
97
        e.printStackTrace();
×
98
      }
99
    }
1✔
100
  }
1✔
101
}
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

© 2025 Coveralls, Inc