当前位置: 首页>>代码示例>>Java>>正文


Java SoftReferenceObjectPool.close方法代码示例

本文整理汇总了Java中org.apache.commons.pool2.impl.SoftReferenceObjectPool.close方法的典型用法代码示例。如果您正苦于以下问题:Java SoftReferenceObjectPool.close方法的具体用法?Java SoftReferenceObjectPool.close怎么用?Java SoftReferenceObjectPool.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.pool2.impl.SoftReferenceObjectPool的用法示例。


在下文中一共展示了SoftReferenceObjectPool.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tryWithResourcesReturnsSoftRefConnectionToPool

import org.apache.commons.pool2.impl.SoftReferenceObjectPool; //导入方法依赖的package包/类
@Test
public void tryWithResourcesReturnsSoftRefConnectionToPool() throws Exception {

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

    StatefulRedisConnection<String, String> usedConnection = null;
    try (StatefulRedisConnection<String, String> connection = pool.borrowObject()) {

        RedisCommands<String, String> sync = connection.sync();
        sync.ping();

        usedConnection = connection;
    }

    try {
        usedConnection.isMulti();
        fail("Missing RedisException");
    } catch (RedisException e) {
        assertThat(e).hasMessageContaining("deallocated");
    }

    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:25,代码来源:ConnectionPoolSupportTest.java

示例2: softReferencePoolShouldWorkWithPlainConnections

import org.apache.commons.pool2.impl.SoftReferenceObjectPool; //导入方法依赖的package包/类
@Test
public void softReferencePoolShouldWorkWithPlainConnections() throws Exception {

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

    borrowAndReturn(pool);

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

    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:ConnectionPoolSupportTest.java

示例3: softRefPoolShouldWorkWithWrappedConnections

import org.apache.commons.pool2.impl.SoftReferenceObjectPool; //导入方法依赖的package包/类
@Test
public void softRefPoolShouldWorkWithWrappedConnections() throws Exception {

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

    StatefulRedisConnection<String, String> connection = pool.borrowObject();

    assertThat(channels).hasSize(1);

    RedisCommands<String, String> sync = connection.sync();
    sync.ping();
    sync.close();

    pool.close();

    Wait.untilTrue(channels::isEmpty).waitOrTimeout();

    assertThat(channels).isEmpty();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:21,代码来源:ConnectionPoolSupportTest.java


注:本文中的org.apache.commons.pool2.impl.SoftReferenceObjectPool.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。