Package org.postgresql.jdbc
Class PgConnectionCleaningAction
- java.lang.Object
-
- org.postgresql.jdbc.PgConnectionCleaningAction
-
- All Implemented Interfaces:
LazyCleaner.CleaningAction<java.io.IOException>
class PgConnectionCleaningAction extends java.lang.Object implements LazyCleaner.CleaningAction<java.io.IOException>
This class segregates the minimal resources required for proper cleanup in case the connection has not been closed by the user code.For now, it has two actions:
- Print stacktrace when the connection has been created, so users can identify the leak
- Release shared timer registration
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Timer
cancelTimer
Timer for scheduling TimerTasks for the connection.private ResourceLock
lock
private static java.util.logging.Logger
LOGGER
private java.lang.Throwable
openStackTrace
private java.io.Closeable
queryExecutorCloseAction
-
Constructor Summary
Constructors Constructor Description PgConnectionCleaningAction(ResourceLock lock, java.lang.Throwable openStackTrace, java.io.Closeable queryExecutorCloseAction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Timer
getTimer()
void
onClean(boolean leak)
void
purgeTimerTasks()
void
releaseTimer()
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
lock
private final ResourceLock lock
-
openStackTrace
private java.lang.Throwable openStackTrace
-
queryExecutorCloseAction
private final java.io.Closeable queryExecutorCloseAction
-
cancelTimer
private java.util.Timer cancelTimer
Timer for scheduling TimerTasks for the connection. Only instantiated if a task is actually scheduled. Access should be guarded withlock
-
-
Constructor Detail
-
PgConnectionCleaningAction
PgConnectionCleaningAction(ResourceLock lock, java.lang.Throwable openStackTrace, java.io.Closeable queryExecutorCloseAction)
-
-
Method Detail
-
getTimer
public java.util.Timer getTimer()
-
releaseTimer
public void releaseTimer()
-
purgeTimerTasks
public void purgeTimerTasks()
-
onClean
public void onClean(boolean leak) throws java.io.IOException
- Specified by:
onClean
in interfaceLazyCleaner.CleaningAction<java.io.IOException>
- Throws:
java.io.IOException
-
-