Github user laurentgo commented on a diff in the pull request:
https://github.com/apache/drill/pull/1024#discussion_r149542468
--- Diff:
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java ---
@@ -139,8 +147,22 @@ private boolean stopThrottlingIfSo() {
return stopped;
}
- public void awaitFirstMessage() throws InterruptedException {
- firstMessageReceived.await();
+ public void awaitFirstMessage() throws InterruptedException,
SQLTimeoutException {
+ //Check if a non-zero timeout has been set
+ if ( parent.timeoutInMilliseconds > 0 ) {
+ //Identifying remaining in milliseconds to maintain a granularity
close to integer value of timeout
+ long timeToTimeout = (parent.timeoutInMilliseconds) -
parent.elapsedTimer.elapsed(TimeUnit.MILLISECONDS);
+ if ( timeToTimeout > 0 ) {
--- End diff --
maybe a style issue, but to avoid code duplication both conditions could be
checked together?
```
if ( timeToTimeout <= 0 || !firstMessageReceived.await(timeToTimeout,
TimeUnit.MILLISECONDS) ) {
throw new
SqlTimeoutException(TimeUnit.MILLISECONDS.toSeconds(parent.timeoutInMilliseconds));
}
```
---