-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #9166 - Jetty 12: review/remove ByteBufferPool #9195
Fixes #9166 - Jetty 12: review/remove ByteBufferPool #9195
Conversation
* Replaced usages of ByteBufferPool with RetainableByteBufferPool. * Removed ByteBufferPool and related classes. Signed-off-by: Simone Bordet <[email protected]>
@gregw @lachlan-roberts @lorban these are the major files to review:
Note in particular that I changed the use of Also changed the One thing open for discussion is whether the Jetty module |
…onsistency. Signed-off-by: Simone Bordet <[email protected]>
{ | ||
bufferPool = new ArrayRetainableByteBufferPool() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a leak tracking RetainableByteBufferPool
implementation? why delete TestableLeakTrackingBufferPool
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it was using the other pool class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why not just update TestableLeakTrackingBufferPool
to be a RetainableByteBufferPool
then other tests can potentially use it.
|
||
@AfterEach | ||
public void afterEach() | ||
{ | ||
bufferPool.assertNoLeaks(); | ||
// TODO: restore leak tracking. | ||
// bufferPool.assertNoLeaks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have these tests been commented out but you have a different change for the same ee9 test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, restore here too.
Signed-off-by: Simone Bordet <[email protected]>
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBufferPool.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBufferPool.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ByteBufferAccumulatorTest.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAccumulator.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ArrayRetainableByteBufferPoolTest.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream2.java
Outdated
Show resolved
Hide resolved
Removed Accumulator.acquire(), and updated code to use RetainableByteBufferPool.acquire() instead. Signed-off-by: Simone Bordet <[email protected]>
Wouldn't it be cool if code like this: RetainableByteBuffer retainableByteBuffer = byteBufferPool.acquire(getBufferSize(), isUseDirectByteBuffers());
ByteBuffer byteBuffer = retainableByteBuffer.getByteBuffer();
int read;
try
{
BufferUtil.clearToFill(byteBuffer);
read = read(channel, byteBuffer);
BufferUtil.flipToFlush(byteBuffer, 0);
}
catch (Throwable x)
{
retainableByteBuffer.release();
return failure(x);
} could become RetainableByteBuffer retainableByteBuffer = byteBufferPool.acquire(getBufferSize(), isUseDirectByteBuffers());
int read;
try
{
read = retainableByteBuffer.fill(channel);
}
catch (Throwable x)
{
retainableByteBuffer.release();
return failure(x);
} The
But that is a different PR :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass.
Generally i think we need to review all our acquires and comment how they are released if it is not obvious.
...http2-common/src/main/java/org/eclipse/jetty/http2/internal/parser/HeaderBlockFragments.java
Show resolved
Hide resolved
...y-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpReceiverOverHTTP.java
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpOutput.java
Show resolved
Hide resolved
jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpOutput.java
Outdated
Show resolved
Hide resolved
jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpOutput.java
Outdated
Show resolved
Hide resolved
...y-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/generator/ServerGenerator.java
Show resolved
Hide resolved
...http2-common/src/main/java/org/eclipse/jetty/http2/internal/parser/HeaderBlockFragments.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found one last problem in fcgi, but we should review the places where Greg found that we may leak a buffer.
And we should document the retain/release doctrine somewhere.
Signed-off-by: Simone Bordet <[email protected]>
…) and super.onCompleteFailure(). Signed-off-by: Simone Bordet <[email protected]>
getBuffer()
togetByteBuffer()
for consistency.Signed-off-by: Simone Bordet [email protected]