db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1500585 - /db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
Date Mon, 08 Jul 2013 06:16:17 GMT
Author: kahatlen
Date: Mon Jul  8 06:16:16 2013
New Revision: 1500585

URL: http://svn.apache.org/r1500585
Log:
DERBY-6167: Interrupt restarts clock for login timeout

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java?rev=1500585&r1=1500584&r2=1500585&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java Mon Jul  8 06:16:16
2013
@@ -305,23 +305,22 @@ public class InternalDriver implements M
     /**
      * Enforce the login timeout.
      */
-    EmbedConnection timeLogin(
+    private EmbedConnection timeLogin(
             String url, Properties info, int loginTimeoutSeconds)
         throws SQLException
     {
         try {
             LoginCallable callable = new LoginCallable(this, url, info);
             Future<EmbedConnection> task = _executorPool.submit(callable);
-            long startTime = System.currentTimeMillis();
-            long interruptedTime = startTime;
+            long now = System.currentTimeMillis();
+            long giveUp = now + loginTimeoutSeconds * 1000L;
 
-            while ((startTime - interruptedTime) / 1000.0
-                        < loginTimeoutSeconds) {
+            while (now < giveUp) {
                 try {
-                    return task.get(loginTimeoutSeconds, TimeUnit.SECONDS);
+                    return task.get(giveUp - now, TimeUnit.MILLISECONDS);
                 } catch (InterruptedException ie) {
-                    interruptedTime = System.currentTimeMillis();
                     InterruptStatus.setInterrupted();
+                    now = System.currentTimeMillis();
                     continue;
                 } catch (ExecutionException ee) {
                     throw processException(ee);



Mime
View raw message