Skip to content

Commit

Permalink
style: compute nanoseconds with TimeUnit.SECONDS.toNanos
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Mar 6, 2020
1 parent 5eabe1a commit b004c70
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ public void testSetQueryTimeout() throws SQLException {
}
}
long duration = System.nanoTime() - start;
if (!cancelReceived || duration > (5E9)) {
if (!cancelReceived || duration > TimeUnit.SECONDS.toNanos(5)) {
fail("Query should have been cancelled since the timeout was set to 1 sec."
+ " Cancel state: " + cancelReceived + ", duration: " + duration);
}
Expand All @@ -723,7 +723,7 @@ public void testLongQueryTimeout() throws SQLException {
public void testShortQueryTimeout() throws SQLException {
assumeLongTest();

long deadLine = System.nanoTime() + 10000 * 1000000;
long deadLine = System.nanoTime() + TimeUnit.SECONDS.toNanos(10);
Statement stmt = con.createStatement();
((PgStatement) stmt).setQueryTimeoutMs(1);
Statement stmt2 = con.createStatement();
Expand Down Expand Up @@ -873,7 +873,7 @@ public Void call() throws Exception {
long start = System.nanoTime();
while (st.getWarnings() == null) {
long dt = System.nanoTime() - start;
if (dt > 10000 * 10000000) {
if (dt > TimeUnit.SECONDS.toNanos(10)) {
throw new IllegalStateException("Expected to receive a notice within 10 seconds");
}
}
Expand Down

0 comments on commit b004c70

Please sign in to comment.