Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x
This commit is contained in:
commit
b57e7eafdd
|
@ -29,12 +29,11 @@ public interface ByteBufferPool
|
|||
{
|
||||
/**
|
||||
* <p>Requests a {@link ByteBuffer} of the given size.</p>
|
||||
* <p>The returned buffer may have a bigger capacity than the size being
|
||||
* requested but it will have the limit set to the given size.</p>
|
||||
* <p>The returned buffer may have a bigger capacity than the size being requested.</p>
|
||||
*
|
||||
* @param size the size of the buffer
|
||||
* @param direct whether the buffer must be direct or not
|
||||
* @return the requested buffer
|
||||
* @return a buffer with at least the requested capacity, with position and limit set to 0.
|
||||
* @see #release(ByteBuffer)
|
||||
*/
|
||||
ByteBuffer acquire(int size, boolean direct);
|
||||
|
|
|
@ -133,6 +133,12 @@ public class MappedByteBufferPool extends AbstractByteBufferPool implements Dump
|
|||
_newBucket = newBucket;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RetainableByteBufferPool newRetainableByteBufferPool(int factor, int maxCapacity, int maxBucketSize, long retainedHeapMemory, long retainedDirectMemory)
|
||||
{
|
||||
return new Retained(factor, maxCapacity, maxBucketSize, retainedHeapMemory, retainedDirectMemory);
|
||||
}
|
||||
|
||||
private Bucket newBucket(int key, boolean direct)
|
||||
{
|
||||
return (_newBucket != null) ? _newBucket.apply(key) : new Bucket(capacityFor(key), getMaxBucketSize(), updateMemory(direct));
|
||||
|
@ -302,4 +308,30 @@ public class MappedByteBufferPool extends AbstractByteBufferPool implements Dump
|
|||
getMaxBucketSize(),
|
||||
getCapacityFactor());
|
||||
}
|
||||
|
||||
protected class Retained extends ArrayRetainableByteBufferPool
|
||||
{
|
||||
public Retained(int factor, int maxCapacity, int maxBucketSize, long retainedHeapMemory, long retainedDirectMemory)
|
||||
{
|
||||
super(0, factor, maxCapacity, maxBucketSize, retainedHeapMemory, retainedDirectMemory);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer allocate(int capacity)
|
||||
{
|
||||
return MappedByteBufferPool.this.acquire(capacity, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer allocateDirect(int capacity)
|
||||
{
|
||||
return MappedByteBufferPool.this.acquire(capacity, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removed(RetainableByteBuffer retainedBuffer)
|
||||
{
|
||||
MappedByteBufferPool.this.release(retainedBuffer.getBuffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface RetainableByteBufferPool
|
|||
* Acquires a memory buffer from the pool.
|
||||
* @param size The size of the buffer. The returned buffer will have at least this capacity.
|
||||
* @param direct true if a direct memory buffer is needed, false otherwise.
|
||||
* @return a memory buffer.
|
||||
* @return a memory buffer with position and size set to 0.
|
||||
*/
|
||||
RetainableByteBuffer acquire(int size, boolean direct);
|
||||
|
||||
|
@ -34,32 +34,41 @@ public interface RetainableByteBufferPool
|
|||
|
||||
static RetainableByteBufferPool from(ByteBufferPool byteBufferPool)
|
||||
{
|
||||
return new RetainableByteBufferPool()
|
||||
return new NotRetainedByteBufferPool(byteBufferPool);
|
||||
}
|
||||
|
||||
class NotRetainedByteBufferPool implements RetainableByteBufferPool
|
||||
{
|
||||
private final ByteBufferPool _byteBufferPool;
|
||||
|
||||
public NotRetainedByteBufferPool(ByteBufferPool byteBufferPool)
|
||||
{
|
||||
@Override
|
||||
public RetainableByteBuffer acquire(int size, boolean direct)
|
||||
{
|
||||
ByteBuffer byteBuffer = byteBufferPool.acquire(size, direct);
|
||||
RetainableByteBuffer retainableByteBuffer = new RetainableByteBuffer(byteBuffer, this::release);
|
||||
retainableByteBuffer.acquire();
|
||||
return retainableByteBuffer;
|
||||
}
|
||||
_byteBufferPool = byteBufferPool;
|
||||
}
|
||||
|
||||
private void release(RetainableByteBuffer retainedBuffer)
|
||||
{
|
||||
byteBufferPool.release(retainedBuffer.getBuffer());
|
||||
}
|
||||
@Override
|
||||
public RetainableByteBuffer acquire(int size, boolean direct)
|
||||
{
|
||||
ByteBuffer byteBuffer = _byteBufferPool.acquire(size, direct);
|
||||
RetainableByteBuffer retainableByteBuffer = new RetainableByteBuffer(byteBuffer, this::release);
|
||||
retainableByteBuffer.acquire();
|
||||
return retainableByteBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
}
|
||||
private void release(RetainableByteBuffer retainedBuffer)
|
||||
{
|
||||
_byteBufferPool.release(retainedBuffer.getBuffer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("NonRetainableByteBufferPool@%x{%s}", hashCode(), byteBufferPool.toString());
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("NonRetainableByteBufferPool@%x{%s}", hashCode(), _byteBufferPool.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,31 @@
|
|||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-random-dependency</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>@junit.version@</version>
|
||||
<type>jar</type>
|
||||
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
|
||||
<destFileName>junit-jupiter-engine.jar</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
@ -92,6 +117,9 @@
|
|||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<webApp>
|
||||
<extraClasspath>${project.build.directory}/dependency/junit-jupiter-engine.jar</extraClasspath>
|
||||
</webApp>
|
||||
<contextXml>${basedir}/src/config/context.xml</contextXml>
|
||||
<systemProperties>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
|
|
|
@ -503,4 +503,11 @@ public class MavenWebAppContext extends WebAppContext
|
|||
LOG.warn("Problem initializing cdi", e);
|
||||
}
|
||||
}
|
||||
|
||||
// need to be overridden to avoid Maven reflection issues with super class and override method
|
||||
public void setExtraClasspath(String extraClasspath) throws IOException
|
||||
{
|
||||
super.setExtraClasspath(extraClasspath);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,12 @@
|
|||
<properties>
|
||||
<osgi-version>3.18.0</osgi-version>
|
||||
<osgi-services-version>3.10.200</osgi-services-version>
|
||||
<osgi-util-version>3.6.100</osgi-util-version>
|
||||
<osgi-util-version>3.7.1</osgi-util-version>
|
||||
<osgi-util-function-version>1.2.0</osgi-util-function-version>
|
||||
<osgi-util-promise-version>1.2.0</osgi-util-promise-version>
|
||||
<osgi-util-measurement-version>1.0.2</osgi-util-measurement-version>
|
||||
<osgi-util-position-version>1.0.1</osgi-util-position-version>
|
||||
<osgi-util-xml-version>1.0.2</osgi-util-xml-version>
|
||||
<equinox-http-servlet-version>1.0.0-v20070606</equinox-http-servlet-version>
|
||||
<jacoco.skip>true</jacoco.skip>
|
||||
</properties>
|
||||
|
|
|
@ -135,6 +135,30 @@
|
|||
<version>1.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.util.promise</artifactId>
|
||||
<version>${osgi-util-promise-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.util.measurement</artifactId>
|
||||
<version>${osgi-util-measurement-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.util.position</artifactId>
|
||||
<version>${osgi-util-position-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.util.xml</artifactId>
|
||||
<version>${osgi-util-xml-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Jetty OSGi Deps -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
|
@ -165,6 +165,11 @@ public class TestOSGiUtil
|
|||
*/
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-jakarta-servlet-api").versionAsInProject().start());
|
||||
res.add(mavenBundle().groupId("org.eclipse.platform").artifactId("org.eclipse.osgi.util").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.osgi").artifactId("org.osgi.util.function").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.osgi").artifactId("org.osgi.util.promise").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.osgi").artifactId("org.osgi.util.measurement").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.osgi").artifactId("org.osgi.util.position").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.osgi").artifactId("org.osgi.util.xml").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.platform").artifactId("org.eclipse.osgi.services").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm").versionAsInProject().start());
|
||||
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm-commons").versionAsInProject().start());
|
||||
|
|
|
@ -206,6 +206,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
}
|
||||
_byteBufferPool = pool;
|
||||
addBean(pool.asRetainableByteBufferPool());
|
||||
|
||||
addEventListener(new Container.Listener()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue