/** * {@inheritDoc} */ public void returnObject(final K key, final V obj) { synchronized (lock) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed } } }
/** * {@inheritDoc} */ public void returnObject(final V obj) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } }
/** * Return an object to the pool, checking its type. * * @param key the associated key (not type-checked) * @param obj the object to return (type-checked) * @throws ClassCastException if obj is not of the expected type */ public void returnObject(final K key, final V obj) { if (type.isInstance(obj)) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } } else { throw new ClassCastException("Returned object for key: " + key + " is not of type: " + type.getName() + " was: " + obj); } }
@Override public void doOperation(int id) throws Exception { Integer key = id % numKeys; String s = (String) pool.borrowObject(key); pool.returnObject(key, s); } };
public Iterable<Result> execute(Query query) throws Exception { JMXConnection jmxConnection = null; try { jmxConnection = pool.borrowObject(this); ImmutableList.Builder<Result> results = ImmutableList.builder(); MBeanServerConnection connection = jmxConnection.getMBeanServerConnection(); for (ObjectName queryName : query.queryNames(connection)) { results.addAll(query.fetchResults(connection, queryName)); } return results.build(); } catch (Exception e) { if (jmxConnection != null) { pool.invalidateObject(this, jmxConnection); jmxConnection = null; } throw e; } finally { if (jmxConnection != null) { pool.returnObject(this, jmxConnection); } } }
keyedPool.invalidateObject(key, obj); } else { keyedPool.returnObject(key, obj);
/** * {@inheritDoc} */ public void returnObject(final V obj) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } }
/** * {@inheritDoc} */ public void returnObject(final K key, final V obj) { synchronized (lock) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed } } }
/** * {@inheritDoc} */ public void returnObject(final K key, final V obj) { synchronized (lock) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed } } }
public void returnObject(final Object obj) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } }
public void releaseConnection(LDAPConnectorConnectionKey key, LDAPConnectorConnectionIdentifierAdapter connection) throws Exception { connectionPool.returnObject(key, connection); }
public void returnObject(final Object obj) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } }
public void returnObject(final Object key, final Object obj) { synchronized (lock) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed } } }
public void releaseConnection(ConnectionManagementConfigTwitterConnectorConnectionKey key, TwitterConnectorConnectionManagementAdapter connection) throws Exception { connectionPool.returnObject(key, connection); }
public void returnObject(final Object key, final Object obj) { synchronized (lock) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed } } }
public void returnObject(final Object key, final Object obj) { if (type.isInstance(obj)) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } } else { throw new ClassCastException("Returned object for key: " + key + " is not of type: " + type.getName() + " was: " + obj); } }
public void returnObject(final Object key, final Object obj) { if (type.isInstance(obj)) { try { keyedPool.returnObject(key, obj); } catch (Exception e) { // swallowed as of Pool 2 } } else { throw new ClassCastException("Returned object for key: " + key + " is not of type: " + type.getName() + " was: " + obj); } }
@Test public void testDoubleClose() throws Exception { final DelegatingDirContext delegatingDirContext = new DelegatingDirContext( keyedObjectPoolMock, dirContextMock, DirContextType.READ_ONLY); delegatingDirContext.close(); // noop close delegatingDirContext.close(); verify(keyedObjectPoolMock, times(1)).returnObject(DirContextType.READ_ONLY, dirContextMock); } }
@Test public void testDoubleClose() throws Exception { final DelegatingContext delegatingContext = new DelegatingContext( keyedObjectPoolMock, contextMock, DirContextType.READ_ONLY); delegatingContext.close(); // noop close delegatingContext.close(); verify(keyedObjectPoolMock, times(1)).returnObject(DirContextType.READ_ONLY, contextMock); }
@Test public void testDoubleClose() throws Exception { final DelegatingLdapContext delegatingLdapContext = new DelegatingLdapContext( keyedObjectPoolMock, ldapContextMock, DirContextType.READ_ONLY); delegatingLdapContext.close(); // noop close delegatingLdapContext.close(); verify(keyedObjectPoolMock, times(1)).returnObject(DirContextType.READ_ONLY, ldapContextMock); } }