parent
b7a4c36286
commit
f3f918ade2
|
@ -1,19 +1,19 @@
|
||||||
//
|
//
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
|
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// All rights reserved. This program and the accompanying materials
|
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
|
||||||
//
|
//
|
||||||
// The Eclipse Public License is available at
|
// This program and the accompanying materials are made available under
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
// the terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
// https://www.eclipse.org/legal/epl-2.0
|
||||||
//
|
//
|
||||||
// The Apache License v2.0 is available at
|
// This Source Code may also be made available under the following
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
// Secondary Licenses when the conditions for such availability set
|
||||||
|
// forth in the Eclipse Public License, v. 2.0 are satisfied:
|
||||||
|
// the Apache License v2.0 which is available at
|
||||||
|
// https://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
package org.eclipse.jetty.util;
|
package org.eclipse.jetty.util;
|
||||||
|
|
|
@ -214,31 +214,6 @@ public class Pool<T> implements AutoCloseable, Dumpable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Acquire the entry from the pool at the specified index. This method bypasses the thread-local mechanism.
|
|
||||||
* @deprecated No longer supported. Instead use a {@link StrategyType} to configure the pool.
|
|
||||||
* @param idx the index of the entry to acquire.
|
|
||||||
* @return the specified entry or null if there is none at the specified index or if it is not available.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Entry acquireAt(int idx)
|
|
||||||
{
|
|
||||||
if (closed)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Entry entry = entries.get(idx);
|
|
||||||
if (entry.tryAcquire())
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
catch (IndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
// no entry at that index
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquire an entry from the pool.
|
* Acquire an entry from the pool.
|
||||||
* Only enabled entries will be returned from this method and their enable method must not be called.
|
* Only enabled entries will be returned from this method and their enable method must not be called.
|
||||||
|
@ -272,7 +247,7 @@ public class Pool<T> implements AutoCloseable, Dumpable
|
||||||
}
|
}
|
||||||
catch (IndexOutOfBoundsException e)
|
catch (IndexOutOfBoundsException e)
|
||||||
{
|
{
|
||||||
LOGGER.ignore(e);
|
LOGGER.trace("IGNORED", e);
|
||||||
size = entries.size();
|
size = entries.size();
|
||||||
}
|
}
|
||||||
index = (index + 1) % size;
|
index = (index + 1) % size;
|
||||||
|
|
|
@ -307,22 +307,6 @@ public class PoolTest
|
||||||
assertThat(pool.values().isEmpty(), is(false));
|
assertThat(pool.values().isEmpty(), is(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource(value = "strategy")
|
|
||||||
public void testAcquireAt(Factory factory)
|
|
||||||
{
|
|
||||||
Pool<String> pool = factory.getPool(2);
|
|
||||||
|
|
||||||
pool.reserve(-1).enable("aaa", false);
|
|
||||||
pool.reserve(-1).enable("bbb", false);
|
|
||||||
|
|
||||||
assertThat(pool.acquireAt(2), nullValue());
|
|
||||||
assertThat(pool.acquireAt(0), notNullValue());
|
|
||||||
assertThat(pool.acquireAt(0), nullValue());
|
|
||||||
assertThat(pool.acquireAt(1), notNullValue());
|
|
||||||
assertThat(pool.acquireAt(1), nullValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource(value = "strategy")
|
@MethodSource(value = "strategy")
|
||||||
public void testMaxUsageCount(Factory factory)
|
public void testMaxUsageCount(Factory factory)
|
||||||
|
|
Loading…
Reference in New Issue