Skip to content
Permalink
Browse files
style: compute nanoseconds with TimeUnit.SECONDS.toNanos
  • Loading branch information
vlsi committed Mar 6, 2020
1 parent 5eabe1a commit b004c706fd7fdb2e05f53eb2cdd4826671c379a4
Showing 1 changed file with 3 additions and 3 deletions.
@@ -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);
}
@@ -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();
@@ -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");
}
}

0 comments on commit b004c70

Please sign in to comment.