Hi Stuart,

Spring Framework 5 uses Undertow APIs directly, i.e. not going through the Servlet API.
When reading the request the ByteBufferPool is obtained from the connection
and then the PooledByteBuffer is allocated and used [1].
Also the PooledByteBuffer is closed in ExchangeCompletionListener [2].

So currently the usage is limited only to the request reading.
In order to extend the usage of the ByteBufferPool we need to be able to allocate buffers with a concrete size.
At the moment (what I saw in the sources) the ByteBufferPool is created with a specific buffer size
and the pooled buffers are created with exactly this size.

For comparison see the io.netty.buffer.PooledByteBufAllocator in Netty
which provides a functionality to allocated buffers with a specific size [3], [4], [5].

So is it possible to achieve the same with the Undertow's ByteBufferPool?
If such functionality is not existing do you think it is feasible to add such API?


[1] https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L144-L148
[2] https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L127-L133
[3] https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/AbstractByteBufAllocator.java#L107-L112
[4] https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L301
[5] https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L318

2017-06-14 3:21 GMT+03:00 Stuart Douglas <sdouglas@redhat.com>:
It should be used anytime you require a large direct buffer (generally
for IO operations). Depending on your app you may not need to use them
directly at all, although Undertow will always use them internally.

The buffers are fixed size which is determined dynamically (unless
explicitly specified), generally they will be 16kb as this seems to
give optimal IO performance.


On Mon, Jun 12, 2017 at 11:06 AM, Violeta Georgieva <milesg78@gmail.com> wrote:
> Hi,
> I have few questions about Undertow's ByteBufferPool.
> Are there any best practices how it should be used?
> Also are the ByteBuffers always fixed in size?
> Thanks,
> Violeta
> _______________________________________________
> undertow-dev mailing list
> undertow-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev