Spring-framework: ExchangeStrategies custom codec's reader and writer are not registered

Created on 28 May 2020  路  5Comments  路  Source: spring-projects/spring-framework

Affects: 5.2.6.RELEASE


I added my custom encoder and decoder like following.

ExchangeStrategies
    .empty()
    .codecs(configurer -> {
        configurer.defaultCodecs().maxInMemorySize(properties.getMaxInMemorySize());
        configurer.customCodecs().registerWithDefaultConfig(encoder);
        configurer.customCodecs().registerWithDefaultConfig(decoder);
    })
    .build();

But there is no messageWriters when writing body with BodyInserts.fromValue().
It seems that encoder and decoder that I added above are not registered at ExchangeStrategies.

I think following code block has bug. Why put all readers and writers from this to other? It seems that this and other are swapped.

https://github.com/spring-projects/spring-framework/blob/90ccabd60bfe24249b3c4cbe43a25ffd0efa6eba/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java#L144-L149

If it is a bug, I would like to create a PR. :)

web bug

All 5 comments

Yes, that looks like a bug.

Feel free to submit a PR with the fix, and please make sure to include a test that fails before the fix and passes afterwards.

This should be backported to 5.1.x as well, but I'm holding off on creating the backport issue with the assumption that a PR from @dlsrb6342 will supersede this issue.

@dlsrb6342 Do you think you'll find time to submit the PR in the coming week?

It would be good to have it in place in time for 5.2.7.

@sbrannen
Please have a look #25149

Superseded by #25149.

Was this page helpful?
0 / 5 - 0 ratings