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

GzipHandler: NPE in setDeflaterPoolCapacity and setInflaterPoolCapacity #6084

Closed
mperktold opened this issue Mar 23, 2021 · 11 comments · Fixed by #6092
Closed

GzipHandler: NPE in setDeflaterPoolCapacity and setInflaterPoolCapacity #6084

mperktold opened this issue Mar 23, 2021 · 11 comments · Fixed by #6092
Assignees

Comments

@mperktold
Copy link

Jetty version
10.0.1

Description
There is a NPE when calling GzipHandler.setDeflaterPoolCapacity or GzipHandler.setInflaterPoolCapacity. The given capacity is passed to the setter of the inflater/deflater pool, but the pool is null before the handler is started, and it is illegal to call the methods on a started handler.

The bug was introduced as a combination of 3bdd82e and 0e3cfe8.

Another minor thing: The JavaDoc of setInflaterPoolCapacity mentions "DeflaterPool" instead of "InflaterPool".

@sbordet
Copy link
Contributor

sbordet commented Mar 23, 2021

@mperktold would you like to submit a pull request?

@mperktold
Copy link
Author

@sbordet I can do that.

Would you prefer to introduce separate fields for the capacities, or to create the pools in the constructor?

@sbordet
Copy link
Contributor

sbordet commented Mar 23, 2021

@mperktold to create the pools you need the server, which is not passed to the constructor, so go with separate fields for the capacities.

@gregw
Copy link
Contributor

gregw commented Mar 23, 2021

Note we will be doing a 10.0.2 release soon, so if @mperktold can do a PR soon then great... if not @lachlan-roberts can you look at this before 10.0.2

@mperktold
Copy link
Author

I wanted to pass the new capacity fields to the corresponding setter of the pools after creating them in doStart, but that doesn't work since the pools returned from ensurePool methods are already started, and changing capacity afterwards is illegal.

Should I pass the capacity as an additional parameter to ensurePool, leaving the current signature as an overload that passes CompressionPool.DEFAULT_CAPACITY?
Should a custom capacity take precedence over CompressionPool.DEFAULT_CAPACITY only or also over the size of the thread pool?

Does it even make sense to specify a custom capacity?

@lachlan-roberts
Copy link
Contributor

I think we should actually just deprecate both these methods. It doesn't seem much correct to have setDeflaterPoolCapacity() and setInflaterPoolCapacity() on the GzipHandler when it is using CompressionPools shared with the whole server.

If you wish to use a pool with a custom capacity you should create the pool yourself and add it as a bean to the server. Then the call to ensure pool in the GzipHandler will return the pre-configured pool it finds on the server.

@mperktold
Copy link
Author

@lachlan-roberts That sounds reasonable to me.

If we choose this path, the deprecated capacity setters wouldn't do anything apart from throwing if already started, right?

@gregw
Copy link
Contributor

gregw commented Mar 23, 2021

I think the deprecated methods should log warnings if called, but otherwise be a noop, but ok to throw if started.

@gregw
Copy link
Contributor

gregw commented Mar 23, 2021

Also planning to build releases in the next 24 to 48 hours

lachlan-roberts added a commit that referenced this issue Mar 24, 2021
lachlan-roberts added a commit that referenced this issue Mar 24, 2021
…pressionPool capacity.

Signed-off-by: Lachlan Roberts <[email protected]>
lachlan-roberts added a commit that referenced this issue Mar 25, 2021
lachlan-roberts added a commit that referenced this issue Mar 31, 2021
…mpressionPool

Issue #6084 - CompressionPools should not be configured through the GzipHandler
@lachlan-roberts
Copy link
Contributor

@mperktold PR #6092 fixes this. It also adds setInflaterPool() and setDeflaterPool() methods to set a custom pool that GzipHandler will use. Otherwise it will use the servers pools which are shared with other things like websocket.

@mperktold
Copy link
Author

Great! Yes, I saw you started working on it, thanks!👍

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 a pull request may close this issue.

4 participants