-
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
Supporting Compression discovery with ServiceLoader. #12611
Supporting Compression discovery with ServiceLoader. #12611
Conversation
joakime
commented
Dec 4, 2024
- New Compressions class to make this easier.
+ New Compressions class to make this easier.
...ssion/jetty-compression-common/src/main/java/org/eclipse/jetty/compression/Compressions.java
Outdated
Show resolved
Hide resolved
...pression-gzip/src/main/resources/META-INF/services/org.eclipse.jetty.compression.Compression
Outdated
Show resolved
Hide resolved
...ion-zstandard/src/main/resources/META-INF/services/org.eclipse.jetty.compression.Compression
Outdated
Show resolved
Hide resolved
/** | ||
* The {@link Compression} implementations available via {@link java.util.ServiceLoader}. | ||
*/ | ||
public class Compressions |
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 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()
.
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.
Removed.
// Fallback to discovered encodings via the service loader instead. | ||
if (supportedEncodings.isEmpty()) | ||
{ | ||
TypeUtil.serviceProviderStream(ServiceLoader.load(Compression.class)).forEach( |
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.
Perhaps it's just simpler to use serviceStream()
here.
} | ||
catch (Throwable e) | ||
{ | ||
LOG.warn("Unable to get Compression", e); |
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.
Use debug
level here, but better yet, use serviceStream()
and get rid of try/catch.
@@ -76,9 +78,6 @@ public CompressionHandler() | |||
|
|||
public void addCompression(Compression compression) |
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.
Please rename this to Compression putCompression(Compression compression)
.
supportedEncodings.put(compression.getEncodingName(), compression); | ||
compression.setContainer(this); | ||
addBean(compression); |
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.
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; |