test_class.declarator: mockPool = createNiceMock(BoneCP.class)
test_class.modifier: private
test_class.original_string: private BoneCP mockPool = createNiceMock(BoneCP.class);
test_class.type: BoneCP
test_class.var_name: mockPool
test_class.declarator: mockLogger
test_class.modifier: private
test_class.original_string: private Logger mockLogger;
test_class.type: Logger
test_class.var_name: mockLogger
test_class.declarator: mockConfig
test_class.modifier: private
test_class.original_string: private BoneCPConfig mockConfig;
test_class.type: BoneCPConfig
test_class.var_name: mockConfig
test_class.declarator: testClass
test_class.modifier: private
test_class.original_string: private ConnectionPartition testClass;
test_class.type: ConnectionPartition
test_class.var_name: testClass
test_class.file: bonecp/src/test/java/com/jolbox/bonecp/TestConnectionPartition.java
test_class.identifier: TestConnectionPartition
test_case.body: @Test
  	public void testFinalizerCoverageException() throws SQLException, InterruptedException{
  		ConnectionHandle mockConnectionHandle = createNiceMock(ConnectionHandle.class);
  		Connection mockConnection = createNiceMock(Connection.class);
  		expect(mockConnectionHandle.getInternalConnection()).andReturn(mockConnection).anyTimes();
  		mockConnection.close();
  		expectLastCall().andThrow(new SQLException("fake reason")).once();
  		reset(this.mockPool);
  		Map<Connection, Reference<ConnectionHandle>> refs = new HashMap<Connection, Reference<ConnectionHandle>>();
  		expect(this.mockPool.getFinalizableRefs()).andReturn(refs).anyTimes();
  		FinalizableReferenceQueue finalizableRefQueue = new FinalizableReferenceQueue();
  		expect(this.mockPool.getFinalizableRefQueue()).andReturn(finalizableRefQueue).anyTimes();
  		expect(mockConnectionHandle.getPool()).andReturn(this.mockPool).anyTimes();
  
  		replay(mockConnectionHandle, mockConnection, this.mockPool);
  		testClass.trackConnectionFinalizer(mockConnectionHandle);
  		testClass.statsLock = null; // this makes it blow up.
  		reset(mockLogger);
  		mockLogger.error((String)anyObject());
  		expectLastCall().anyTimes();
  		replay(mockLogger);
  		reset(mockConnectionHandle);
  		mockConnectionHandle = null; // prompt GC to kick in
  		for (int i=0; i < 100; i++){
  			System.gc();System.gc();System.gc();
  			Thread.sleep(20);
  			try{
  				verify(mockLogger);
  				break; // we succeeded
  			} catch (Throwable t){
  				// do nothing, try again
  				Thread.sleep(20);
  			}
  		}
  	}
test_case.class_method_signature: TestConnectionPartition.testFinalizerCoverageException()
test_case.full_signature: @Test public void testFinalizerCoverageException()
test_case.identifier: testFinalizerCoverageException
test_case.invocations: createNiceMock createNiceMock anyTimes andReturn expect getInternalConnection close once andThrow expectLastCall reset anyTimes andReturn expect getFinalizableRefs anyTimes andReturn expect getFinalizableRefQueue anyTimes andReturn expect getPool replay trackConnectionFinalizer reset error anyObject anyTimes expectLastCall replay reset gc gc gc sleep verify sleep
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFinalizerCoverageException()
focal_class.declarator: serialVersionUID = -7864443421028454573L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = -7864443421028454573L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: logger = LoggerFactory.getLogger(ConnectionPartition.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ConnectionPartition.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: freeConnections
focal_class.modifier: private
focal_class.original_string: private BlockingQueue<ConnectionHandle> freeConnections;
focal_class.type: BlockingQueue<ConnectionHandle>
focal_class.var_name: freeConnections
focal_class.declarator: acquireIncrement
focal_class.modifier: private final
focal_class.original_string: private final int acquireIncrement;
focal_class.type: int
focal_class.var_name: acquireIncrement
focal_class.declarator: minConnections
focal_class.modifier: private final
focal_class.original_string: private final int minConnections;
focal_class.type: int
focal_class.var_name: minConnections
focal_class.declarator: maxConnections
focal_class.modifier: private final
focal_class.original_string: private final int maxConnections;
focal_class.type: int
focal_class.var_name: maxConnections
focal_class.declarator: statsLock = new ReentrantReadWriteLock()
focal_class.modifier: protected
focal_class.original_string: protected ReentrantReadWriteLock statsLock = new ReentrantReadWriteLock();
focal_class.type: ReentrantReadWriteLock
focal_class.var_name: statsLock
focal_class.declarator: createdConnections=0
focal_class.modifier: private
focal_class.original_string: private int createdConnections=0;
focal_class.type: int
focal_class.var_name: createdConnections
focal_class.declarator: url
focal_class.modifier: private final
focal_class.original_string: private final String url;
focal_class.type: String
focal_class.var_name: url
focal_class.declarator: username
focal_class.modifier: private final
focal_class.original_string: private final String username;
focal_class.type: String
focal_class.var_name: username
focal_class.declarator: password
focal_class.modifier: private final
focal_class.original_string: private final String password;
focal_class.type: String
focal_class.var_name: password
focal_class.declarator: unableToCreateMoreTransactions=false
focal_class.modifier: private volatile
focal_class.original_string: private volatile boolean unableToCreateMoreTransactions=false;
focal_class.type: boolean
focal_class.var_name: unableToCreateMoreTransactions
focal_class.declarator: disableTracking
focal_class.modifier: private
focal_class.original_string: private boolean disableTracking;
focal_class.type: boolean
focal_class.var_name: disableTracking
focal_class.declarator: poolWatchThreadSignalQueue = new ArrayBlockingQueue<Object>(1)
focal_class.modifier: private
focal_class.original_string: private BlockingQueue<Object> poolWatchThreadSignalQueue = new ArrayBlockingQueue<Object>(1);
focal_class.type: BlockingQueue<Object>
focal_class.var_name: poolWatchThreadSignalQueue
focal_class.declarator: queryExecuteTimeLimitInNanoSeconds
focal_class.modifier: private
focal_class.original_string: private long queryExecuteTimeLimitInNanoSeconds;
focal_class.type: long
focal_class.var_name: queryExecuteTimeLimitInNanoSeconds
focal_class.declarator: poolName
focal_class.modifier: private
focal_class.original_string: private String poolName;
focal_class.type: String
focal_class.var_name: poolName
focal_class.declarator: pool
focal_class.modifier: protected
focal_class.original_string: protected BoneCP pool;
focal_class.type: BoneCP
focal_class.var_name: pool
focal_class.file: bonecp/src/main/java/com/jolbox/bonecp/ConnectionPartition.java
focal_class.identifier: ConnectionPartition
focal_class.interfaces: implements Serializable
focal_class.class_method_signature: ConnectionPartition.getPoolWatchThreadSignalQueue()
focal_class.full_signature: protected BlockingQueue<Object> getPoolWatchThreadSignalQueue()
focal_class.identifier: getPoolWatchThreadSignalQueue
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: BlockingQueue<Object>
focal_class.signature: BlockingQueue<Object> getPoolWatchThreadSignalQueue()
focal_class.class_method_signature: ConnectionPartition.updateCreatedConnections(int increment)
focal_class.full_signature: protected void updateCreatedConnections(int increment)
focal_class.identifier: updateCreatedConnections
focal_class.modifiers: protected
focal_class.parameters: (int increment)
focal_class.return: void
focal_class.signature: void updateCreatedConnections(int increment)
focal_class.class_method_signature: ConnectionPartition.addFreeConnection(ConnectionHandle connectionHandle)
focal_class.full_signature: protected void addFreeConnection(ConnectionHandle connectionHandle)
focal_class.identifier: addFreeConnection
focal_class.modifiers: protected
focal_class.parameters: (ConnectionHandle connectionHandle)
focal_class.return: void
focal_class.signature: void addFreeConnection(ConnectionHandle connectionHandle)
focal_class.class_method_signature: ConnectionPartition.trackConnectionFinalizer(ConnectionHandle connectionHandle)
focal_class.full_signature: protected void trackConnectionFinalizer(ConnectionHandle connectionHandle)
focal_class.identifier: trackConnectionFinalizer
focal_class.modifiers: protected
focal_class.parameters: (ConnectionHandle connectionHandle)
focal_class.return: void
focal_class.signature: void trackConnectionFinalizer(ConnectionHandle connectionHandle)
focal_class.class_method_signature: ConnectionPartition.getFreeConnections()
focal_class.full_signature: protected BlockingQueue<ConnectionHandle> getFreeConnections()
focal_class.identifier: getFreeConnections
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: BlockingQueue<ConnectionHandle>
focal_class.signature: BlockingQueue<ConnectionHandle> getFreeConnections()
focal_class.class_method_signature: ConnectionPartition.setFreeConnections(BlockingQueue<ConnectionHandle> freeConnections)
focal_class.full_signature: protected void setFreeConnections(BlockingQueue<ConnectionHandle> freeConnections)
focal_class.identifier: setFreeConnections
focal_class.modifiers: protected
focal_class.parameters: (BlockingQueue<ConnectionHandle> freeConnections)
focal_class.return: void
focal_class.signature: void setFreeConnections(BlockingQueue<ConnectionHandle> freeConnections)
focal_class.class_method_signature: ConnectionPartition.ConnectionPartition(BoneCP pool)
focal_class.full_signature: public  ConnectionPartition(BoneCP pool)
focal_class.identifier: ConnectionPartition
focal_class.modifiers: public
focal_class.parameters: (BoneCP pool)
focal_class.signature:  ConnectionPartition(BoneCP pool)
focal_class.class_method_signature: ConnectionPartition.getAcquireIncrement()
focal_class.full_signature: protected int getAcquireIncrement()
focal_class.identifier: getAcquireIncrement
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getAcquireIncrement()
focal_class.class_method_signature: ConnectionPartition.getMinConnections()
focal_class.full_signature: protected int getMinConnections()
focal_class.identifier: getMinConnections
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMinConnections()
focal_class.class_method_signature: ConnectionPartition.getMaxConnections()
focal_class.full_signature: protected int getMaxConnections()
focal_class.identifier: getMaxConnections
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMaxConnections()
focal_class.class_method_signature: ConnectionPartition.getCreatedConnections()
focal_class.full_signature: protected int getCreatedConnections()
focal_class.identifier: getCreatedConnections
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getCreatedConnections()
focal_class.class_method_signature: ConnectionPartition.getUrl()
focal_class.full_signature: protected String getUrl()
focal_class.identifier: getUrl
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getUrl()
focal_class.class_method_signature: ConnectionPartition.getUsername()
focal_class.full_signature: protected String getUsername()
focal_class.identifier: getUsername
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getUsername()
focal_class.class_method_signature: ConnectionPartition.getPassword()
focal_class.full_signature: protected String getPassword()
focal_class.identifier: getPassword
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getPassword()
focal_class.class_method_signature: ConnectionPartition.isUnableToCreateMoreTransactions()
focal_class.full_signature: protected boolean isUnableToCreateMoreTransactions()
focal_class.identifier: isUnableToCreateMoreTransactions
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isUnableToCreateMoreTransactions()
focal_class.class_method_signature: ConnectionPartition.setUnableToCreateMoreTransactions(boolean unableToCreateMoreTransactions)
focal_class.full_signature: protected void setUnableToCreateMoreTransactions(boolean unableToCreateMoreTransactions)
focal_class.identifier: setUnableToCreateMoreTransactions
focal_class.modifiers: protected
focal_class.parameters: (boolean unableToCreateMoreTransactions)
focal_class.return: void
focal_class.signature: void setUnableToCreateMoreTransactions(boolean unableToCreateMoreTransactions)
focal_class.class_method_signature: ConnectionPartition.getAvailableConnections()
focal_class.full_signature: protected int getAvailableConnections()
focal_class.identifier: getAvailableConnections
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getAvailableConnections()
focal_class.class_method_signature: ConnectionPartition.getRemainingCapacity()
focal_class.full_signature: public int getRemainingCapacity()
focal_class.identifier: getRemainingCapacity
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getRemainingCapacity()
focal_class.class_method_signature: ConnectionPartition.getQueryExecuteTimeLimitinNanoSeconds()
focal_class.full_signature: protected long getQueryExecuteTimeLimitinNanoSeconds()
focal_class.identifier: getQueryExecuteTimeLimitinNanoSeconds
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getQueryExecuteTimeLimitinNanoSeconds()
focal_class.class_method_signature: ConnectionPartition.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_method.body: protected void trackConnectionFinalizer(ConnectionHandle connectionHandle) {
  		if (!this.disableTracking){
  		//	assert !connectionHandle.getPool().getFinalizableRefs().containsKey(connectionHandle) : "Already tracking this handle";
  			Connection con = connectionHandle.getInternalConnection();
  			if (con != null && con instanceof Proxy && Proxy.getInvocationHandler(con) instanceof MemorizeTransactionProxy){
  				try {
  					// if this is a proxy, get the correct target so that when we call close we're actually calling close on the database
  					// handle and not a proxy-based close.
  					con = (Connection) Proxy.getInvocationHandler(con).invoke(con, ConnectionHandle.class.getMethod("getProxyTarget"), null);
  				} catch (Throwable t) {
  					logger.error("Error while attempting to track internal db connection", t); // should never happen
  				}
  			}
  			final Connection internalDBConnection = con;
  			final BoneCP pool = connectionHandle.getPool();
  			connectionHandle.getPool().getFinalizableRefs().put(internalDBConnection, new FinalizableWeakReference<ConnectionHandle>(connectionHandle, connectionHandle.getPool().getFinalizableRefQueue()) {
  				@SuppressWarnings("synthetic-access")
  				public void finalizeReferent() {
  					try {
  						pool.getFinalizableRefs().remove(internalDBConnection);
  						if (internalDBConnection != null && !internalDBConnection.isClosed()){ // safety!
  							
  							logger.warn("BoneCP detected an unclosed connection "+ConnectionPartition.this.poolName + "and will now attempt to close it for you. " +
  							"You should be closing this connection in your application - enable connectionWatch for additional debugging assistance or set disableConnectionTracking to true to disable this feature entirely.");
  							internalDBConnection.close();
  							updateCreatedConnections(-1);
  						}
  					} catch (Throwable t) {
  						logger.error("Error while closing off internal db connection", t);
  					}
  				}
  			});
  		}
  	}
focal_method.class_method_signature: ConnectionPartition.trackConnectionFinalizer(ConnectionHandle connectionHandle)
focal_method.full_signature: protected void trackConnectionFinalizer(ConnectionHandle connectionHandle)
focal_method.identifier: trackConnectionFinalizer
focal_method.invocations: getInternalConnection getInvocationHandler invoke getInvocationHandler getMethod error getPool put getFinalizableRefs getPool getFinalizableRefQueue getPool remove getFinalizableRefs isClosed warn close updateCreatedConnections error
focal_method.modifiers: protected
focal_method.parameters: (ConnectionHandle connectionHandle)
focal_method.return: void
focal_method.signature: void trackConnectionFinalizer(ConnectionHandle connectionHandle)