Skip to content
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

Fix Caching ContentFactories in Jetty-12 #8621

Merged
merged 9 commits into from
Oct 4, 2022

Conversation

lachlan-roberts
Copy link
Contributor

This PR removes the old CachedContentFactory which was only used in tests, and brings over some of its functionality to the CachingContentFactory.

Fixes the CachingContentFactory to make it pass tests, and re-enable the tests.

Copy link
Contributor

@joakime joakime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore the writeHttpError usage.

Note that the removal of a header from the response has to be done through the Servlet API (in case of wrapping), so that raw ETAG removal also needs to be done at the Servlet level.

@joakime joakime dismissed their stale review September 28, 2022 21:11

Haven't had a chance to review yet

Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things, please fix them, but LGTM.

}

@Override
public void release()
{
_content.release();
_precompressedContent.release();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not release both _content and _precompressedContent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. The _content will be accessible separately to the pre-compressed version and will have separate entry in the cache, so maybe this would result in a double release?

At the moment it looks there are no implementations of HttpContent.release() which actually do anything, so this currently has no effect.

{
return !resource2.lastModified().isAfter(resource1.lastModified());
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the original version more readable, but ok.
Rename to isNewerThanOrEqual().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original version was wrong and was causing many test failures.

Copy link
Contributor

@lorban lorban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpContent should implement Retainable otherwise we may leak resources or release them while they're in use. But that should be addressed in another PR IMHO.

@lachlan-roberts lachlan-roberts merged commit 05a4b96 into jetty-12.0.x Oct 4, 2022
@lachlan-roberts lachlan-roberts deleted the jetty-12.0.x-CachedContentFactory branch October 4, 2022 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants