Example usage for org.apache.commons.pool2.impl SoftReferenceObjectPool returnObject

List of usage examples for org.apache.commons.pool2.impl SoftReferenceObjectPool returnObject

Introduction

In this page you can find the example usage for org.apache.commons.pool2.impl SoftReferenceObjectPool returnObject.

Prototype

@Override
public synchronized void returnObject(T obj) throws Exception 

Source Link

Document

Returns an instance to the pool after successful validation and passivation.

Usage

From source file:com.lambdaworks.redis.support.ConnectionPoolSupportTest.java

@Test
public void softReferencePoolShouldWorkWithPlainConnections() throws Exception {

    SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport
            .createSoftReferenceObjectPool(() -> client.connect(), false);

    borrowAndReturn(pool);//www. jav a  2  s  . c o m

    StatefulRedisConnection<String, String> connection = pool.borrowObject();
    assertThat(Proxy.isProxyClass(connection.getClass())).isFalse();
    pool.returnObject(connection);

    pool.close();
}

From source file:io.lettuce.core.support.ConnectionPoolSupportTest.java

@Test
public void softReferencePoolShouldWorkWithPlainConnections() throws Exception {

    SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport
            .createSoftReferenceObjectPool(() -> client.connect(), false);

    borrowAndReturn(pool);/*from  w  w w  . ja va  2 s .  c  o m*/

    StatefulRedisConnection<String, String> connection = pool.borrowObject();
    assertThat(Proxy.isProxyClass(connection.getClass())).isFalse();
    pool.returnObject(connection);

    connection.close();
    pool.close();
}