test_class.declarator: mockCache
test_class.modifier: private
test_class.original_string: private IStatementCache mockCache;
test_class.type: IStatementCache
test_class.var_name: mockCache
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: config
test_class.modifier: private
test_class.original_string: private BoneCPConfig config;
test_class.type: BoneCPConfig
test_class.var_name: config
test_class.declarator: driver
test_class.modifier: private
test_class.original_string: private MockJDBCDriver driver;
test_class.type: MockJDBCDriver
test_class.var_name: driver
test_class.file: bonecp/src/test/java/com/jolbox/bonecp/TestStatementCache.java
test_class.identifier: TestStatementCache
test_case.body: @Test
  	public void testStatementCachePut() throws SQLException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{
  		CommonTestUtils.logTestInfo("Tests statement close (put in cache).");
  		String sql = CommonTestUtils.TEST_QUERY;
  		BoneCP dsb = null ;
  		config.setMinConnectionsPerPartition(1);
  		config.setMaxConnectionsPerPartition(5);
  		config.setAcquireIncrement(1);
  		config.setPartitionCount(1);
  		config.setStatementsCacheSize(5);
  		config.setStatementReleaseHelperThreads(0);
  		config.setStatisticsEnabled(true);
  		dsb = new BoneCP(config);
  		Connection conn = dsb.getConnection();
  		Statement statement = conn.prepareStatement(sql);
  		statement.close();
  		Field statementCache = conn.getClass().getDeclaredField("preparedStatementCache");
  		statementCache.setAccessible(true);
  		IStatementCache cache = (IStatementCache) statementCache.get(conn);
  		
  		statement = cache.get(sql);
  		assertNotNull(statement);
  		// Calling again should not provide the same object
  		assertNull(cache.get(sql));
  
  		// now pretend we have 1 connection being asked for the same statement
  		// twice
  		statement = conn.prepareStatement(sql);
  		Statement statement2 = conn.prepareStatement(sql);
  
  		statement.close(); // release it again
  		statement2.close(); // release the other one
  
  		statement2.close();
  		statement.close();
  		conn.close();
  		dsb.shutdown();
  		
  		dsb.close();
  		
  		CommonTestUtils.logPass();
  	}
test_case.class_method_signature: TestStatementCache.testStatementCachePut()
test_case.full_signature: @Test public void testStatementCachePut()
test_case.identifier: testStatementCachePut
test_case.invocations: logTestInfo setMinConnectionsPerPartition setMaxConnectionsPerPartition setAcquireIncrement setPartitionCount setStatementsCacheSize setStatementReleaseHelperThreads setStatisticsEnabled getConnection prepareStatement close getDeclaredField getClass setAccessible get get assertNotNull assertNull get prepareStatement prepareStatement close close close close close shutdown close logPass
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testStatementCachePut()
focal_class.declarator: logger = LoggerFactory.getLogger(StatementCache.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(StatementCache.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: cache
focal_class.modifier: private
focal_class.original_string: private ConcurrentMap<String, StatementHandle> cache;
focal_class.type: ConcurrentMap<String, StatementHandle>
focal_class.var_name: cache
focal_class.declarator: cacheSize
focal_class.modifier: private
focal_class.original_string: private int cacheSize;
focal_class.type: int
focal_class.var_name: cacheSize
focal_class.declarator: maintainStats
focal_class.modifier: private final
focal_class.original_string: private final boolean maintainStats;
focal_class.type: boolean
focal_class.var_name: maintainStats
focal_class.declarator: statistics
focal_class.modifier: private final
focal_class.original_string: private final Statistics statistics;
focal_class.type: Statistics
focal_class.var_name: statistics
focal_class.file: bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java
focal_class.identifier: StatementCache
focal_class.interfaces: implements IStatementCache
focal_class.class_method_signature: StatementCache.StatementCache(int size, boolean maintainStats, Statistics statistics)
focal_class.full_signature: public  StatementCache(int size, boolean maintainStats, Statistics statistics)
focal_class.identifier: StatementCache
focal_class.modifiers: public
focal_class.parameters: (int size, boolean maintainStats, Statistics statistics)
focal_class.signature:  StatementCache(int size, boolean maintainStats, Statistics statistics)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.full_signature: public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency)
focal_class.full_signature: public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency)
focal_class.class_method_signature: StatementCache.calculateCacheKeyInternal(String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.full_signature: private StringBuilder calculateCacheKeyInternal(String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.identifier: calculateCacheKeyInternal
focal_class.modifiers: private
focal_class.parameters: (String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.return: StringBuilder
focal_class.signature: StringBuilder calculateCacheKeyInternal(String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int autoGeneratedKeys)
focal_class.full_signature: public String calculateCacheKey(String sql, int autoGeneratedKeys)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int autoGeneratedKeys)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int autoGeneratedKeys)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int[] columnIndexes)
focal_class.full_signature: public String calculateCacheKey(String sql, int[] columnIndexes)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int[] columnIndexes)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int[] columnIndexes)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, String[] columnNames)
focal_class.full_signature: public String calculateCacheKey(String sql, String[] columnNames)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, String[] columnNames)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, String[] columnNames)
focal_class.class_method_signature: StatementCache.get(String key)
focal_class.full_signature: public StatementHandle get(String key)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String key)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String key)
focal_class.class_method_signature: StatementCache.get(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.full_signature: public StatementHandle get(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.class_method_signature: StatementCache.get(String sql, int resultSetType, int resultSetConcurrency)
focal_class.full_signature: public StatementHandle get(String sql, int resultSetType, int resultSetConcurrency)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int resultSetType, int resultSetConcurrency)
focal_class.class_method_signature: StatementCache.get(String sql, int autoGeneratedKeys)
focal_class.full_signature: public StatementHandle get(String sql, int autoGeneratedKeys)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int autoGeneratedKeys)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int autoGeneratedKeys)
focal_class.class_method_signature: StatementCache.get(String sql, int[] columnIndexes)
focal_class.full_signature: public StatementHandle get(String sql, int[] columnIndexes)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int[] columnIndexes)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int[] columnIndexes)
focal_class.class_method_signature: StatementCache.get(String sql, String[] columnNames)
focal_class.full_signature: public StatementHandle get(String sql, String[] columnNames)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, String[] columnNames)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, String[] columnNames)
focal_class.class_method_signature: StatementCache.size()
focal_class.full_signature: public int size()
focal_class.identifier: size
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_class.class_method_signature: StatementCache.clear()
focal_class.full_signature: public void clear()
focal_class.identifier: clear
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clear()
focal_class.class_method_signature: StatementCache.checkForProperClosure()
focal_class.full_signature: public void checkForProperClosure()
focal_class.identifier: checkForProperClosure
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void checkForProperClosure()
focal_class.class_method_signature: StatementCache.putIfAbsent(String key, StatementHandle handle)
focal_class.full_signature: public void putIfAbsent(String key, StatementHandle handle)
focal_class.identifier: putIfAbsent
focal_class.modifiers: public
focal_class.parameters: (String key, StatementHandle handle)
focal_class.return: void
focal_class.signature: void putIfAbsent(String key, StatementHandle handle)
focal_method.body: public StatementHandle get(String key){
  		StatementHandle statement = this.cache.get(key);
  		
  		if (statement != null && !statement.logicallyClosed.compareAndSet(true, false)){
  			statement = null;
  		}
  		
  		if (this.maintainStats){
  			if (statement != null){
  				this.statistics.incrementCacheHits();
  			} else {
  				this.statistics.incrementCacheMiss();
  			}
  		}
  		return statement;
  	}
focal_method.class_method_signature: StatementCache.get(String key)
focal_method.full_signature: public StatementHandle get(String key)
focal_method.identifier: get
focal_method.invocations: get compareAndSet incrementCacheHits incrementCacheMiss
focal_method.modifiers: public
focal_method.parameters: (String key)
focal_method.return: StatementHandle
focal_method.signature: StatementHandle get(String key)