Skip to content

Conversation

@schiemon
Copy link
Contributor

@schiemon schiemon commented Sep 14, 2025

Motivation

From #6390:

We encountered an issue where the deflate encoding algorithm used by EncodingService is incompatible with our VPN infrastructure, causing connection failures. Currently, there is no way to disable or exclude specific encoding algorithms.

Modifications

  • Moved StreamEncoderFactory, StreamEncoderFactories, and SnappyFramedOutputStream from com.linecorp.armeria.internal.common.encoding to com.linecorp.armeria.common.encoding to enable their use in EncoderService and related components.

  • Modified HttpEncoders.determineEncoder to accept a map of StreamEncoderFactorys that defines the available StreamEncoderFactory instances. The * wildcard now only refers to factories present in the provided map.

  • Added the following methods to EncodingService:

    Function<? super HttpService, EncodingService>
        newDecorator(Iterable<? extends StreamEncoderFactory> encoderFactories)
    Function<? super HttpService, EncodingService>
        newDecorator(StreamEncoderFactory... encoderFactories) 

    These methods allow setting the factories that EncodingService will pass to HttpEncoder when determining the appropriate factory from the Accept-Encoding header.

  • Added following methods to EncoderServiceBuilder:

EncodingServiceBuilder encoderFactories(Iterable<? extends StreamEncoderFactory> encoderFactories)
EncodingServiceBuilder encoderFactories(StreamEncoderFactory... encoderFactories)

Result

Closes #6390. Users can now explicitly control which StreamEncoderFactory instances EncodingService will use for each Accept-Encoding header value.

Usage example:

EncodingService
    .builder()
    .encoderFactories(
        // handles "gzip"
        StreamEncoderFactories.GZIP,
        // handles "deflate"
        StreamEncoderFactories.DEFLATE,
        // handles "br"
        new CustomBrotliEncoderFactory()
     )
    .build(delegate);

@schiemon schiemon changed the title feat: allow setting allow list of encoding (factories) in EncodingSer… feat: allow list of encoding (factories) in EncodingService Sep 14, 2025
@schiemon schiemon changed the title feat: allow list of encoding (factories) in EncodingService feat: allow explicitly enabling/disabling of encodings in EncodingService Sep 15, 2025
@codecov
Copy link

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.11%. Comparing base (8150425) to head (477799e).
⚠️ Report is 203 commits behind head on main.

Files with missing lines Patch % Lines
...ecorp/armeria/server/encoding/EncodingService.java 45.45% 6 Missing ⚠️
...linecorp/armeria/server/encoding/HttpEncoders.java 86.66% 3 Missing and 1 partial ⚠️
...rmeria/common/encoding/StreamEncoderFactories.java 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6398      +/-   ##
============================================
- Coverage     74.46%   74.11%   -0.36%     
- Complexity    22234    23005     +771     
============================================
  Files          1963     2062      +99     
  Lines         82437    86154    +3717     
  Branches      10764    11310     +546     
============================================
+ Hits          61385    63851    +2466     
- Misses        15918    16890     +972     
- Partials       5134     5413     +279     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@schiemon schiemon marked this pull request as ready for review September 15, 2025 08:56
@schiemon schiemon requested a review from jrhee17 September 16, 2025 08:53
@minwoox minwoox added this to the 1.34.0 milestone Sep 19, 2025
Just leave a general link to the RFC and expect that users will open the RFC side-by-side.
Copy link
Contributor Author

@schiemon schiemon left a comment

Choose a reason for hiding this comment

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

@ikhoon
Copy link
Contributor

ikhoon commented Sep 22, 2025

Not sure if we need it:

If tests are not broken, we may remove it.

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Overall looks good

- adjust some style
- transition from block to line comments
Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@schiemon
Copy link
Contributor Author

schiemon commented Oct 9, 2025

@ikhoon May I ask for another review to get a ✅ ? :)

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks! 👍👍

@ikhoon ikhoon merged commit 4bc21ed into line:main Oct 20, 2025
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a mechanism to exclude specific encoding algorithms from EncodingService

4 participants