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

Supporting Compression discovery with ServiceLoader. #12611

Merged
merged 6 commits into from
Dec 5, 2024

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Dec 4, 2024

  • New Compressions class to make this easier.

+ New Compressions class to make this easier.
@joakime joakime requested a review from sbordet December 4, 2024 15:34
@joakime joakime self-assigned this Dec 4, 2024
/**
* The {@link Compression} implementations available via {@link java.util.ServiceLoader}.
*/
public class Compressions
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this class is necessary.

In the proxy case, we do not want both client and server to reference the same JVM singleton, but rather have each its own instance, for example to support different configurations.

The client will look the compressions in HttpClient.doStart(), and the server could do the same in CompressionHandler.doStart().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@joakime joakime requested review from sbordet and gregw December 5, 2024 14:09
// Fallback to discovered encodings via the service loader instead.
if (supportedEncodings.isEmpty())
{
TypeUtil.serviceProviderStream(ServiceLoader.load(Compression.class)).forEach(
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it's just simpler to use serviceStream() here.

}
catch (Throwable e)
{
LOG.warn("Unable to get Compression", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use debug level here, but better yet, use serviceStream() and get rid of try/catch.

@joakime joakime requested a review from sbordet December 5, 2024 14:15
@@ -76,9 +78,6 @@ public CompressionHandler()

public void addCompression(Compression compression)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this to Compression putCompression(Compression compression).

Comment on lines 81 to 83
supportedEncodings.put(compression.getEncodingName(), compression);
compression.setContainer(this);
addBean(compression);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
supportedEncodings.put(compression.getEncodingName(), compression);
compression.setContainer(this);
addBean(compression);
Compression existing = supportedEncodings.put(compression.getEncodingName(), compression);
compression.setContainer(this);
updateBean(existing, compression, true);
return existing;

@joakime joakime merged commit 60e8ebe into jetty-12.1.x Dec 5, 2024
2 of 4 checks passed
@joakime joakime deleted the fix/12.1.x/compression-handler-service-loader branch December 5, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants