Package org.postgresql
Class Driver.ConnectTask
java.lang.Object
org.postgresql.Driver.ConnectTask
- All Implemented Interfaces:
Runnable
- Enclosing class:
Driver
Perform a connect in a separate thread; supports getting the results from the original thread
while enforcing a login timeout.
If the caller times out or is interrupted, we mark the attempt as abandoned and try to cancel the worker thread. Cancellation is best-effort: if the connection attempt does not stop immediately, the worker closes any connection it manages to establish after abandonment so that it does not leak.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final AtomicReference<Connection> private final FutureTask<Connection> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidabandon()private static voidcloseConnection(Connection conn) (package private) ConnectiongetResult(long timeout) Get the connection result from this (assumed running) task.voidrun()
-
Field Details
-
abandoned
private volatile boolean abandoned -
establishedConnection
-
futureTask
-
-
Constructor Details
-
ConnectTask
ConnectTask(String url, Properties props)
-
-
Method Details
-
run
public void run() -
getResult
Get the connection result from this (assumed running) task. If the timeout is reached without a result being available, a SQLException is thrown.- Parameters:
timeout- timeout in milliseconds- Returns:
- the new connection, if successful
- Throws:
SQLException- if a connection error occurs or the timeout is reached
-
abandon
private void abandon() -
closeConnection
-