Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eng/versioning/external_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ springboot4_org.springframework.boot:spring-boot-actuator;4.0.6
springboot4_org.springframework.boot:spring-boot-autoconfigure;4.0.6
springboot4_org.springframework.boot:spring-boot-configuration-metadata;4.0.6
springboot4_org.springframework.boot:spring-boot-configuration-processor;4.0.6
springboot4_org.springframework.boot:spring-boot-data-commons;4.0.6
springboot4_org.springframework.boot:spring-boot-data-redis;4.0.6
springboot4_org.springframework.boot:spring-boot-docker-compose;4.0.6
springboot4_org.springframework.boot:spring-boot-health;4.0.6
Expand All @@ -366,6 +367,7 @@ springboot4_org.springframework.boot:spring-boot-test;4.0.6
springboot4_org.springframework.boot:spring-boot-testcontainers;4.0.6
springboot4_org.springframework.cloud:spring-cloud-bus;5.0.1
springboot4_org.springframework.cloud:spring-cloud-context;5.0.1
springboot4_org.springframework.cloud:spring-cloud-starter-openfeign;5.0.1
springboot4_org.springframework.cloud:spring-cloud-starter-stream-kafka;5.0.1
springboot4_org.springframework.cloud:spring-cloud-stream-test-binder;5.0.1
springboot4_org.springframework.cloud:spring-cloud-stream;5.0.1
Expand Down
2 changes: 2 additions & 0 deletions sdk/spring/azure-spring-data-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#### Bugs Fixed

* Fixed a bug where using `azure-spring-data-cosmos` with OpenFeign on Spring Boot 4 failed at startup with `IllegalStateException: No bean found of type interface feign.codec.Encoder` by adding the `spring-boot-data-commons` dependency ([49441](https://github.com/Azure/azure-sdk-for-java/issues/49441)).

#### Other Changes

### 6.4.0 (2026-06-01)
Expand Down
15 changes: 15 additions & 0 deletions sdk/spring/azure-spring-data-cosmos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
<artifactId>spring-boot-persistence</artifactId>
<version>4.0.6</version> <!-- {x-version-update;springboot4_org.springframework.boot:spring-boot-persistence;external_dependency} -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-data-commons</artifactId>
<version>4.0.6</version> <!-- {x-version-update;springboot4_org.springframework.boot:spring-boot-data-commons;external_dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos</artifactId>
Expand Down Expand Up @@ -133,6 +138,15 @@
</dependency>

<!-- Test -->
<!-- Used to verify the fix for https://github.com/Azure/azure-sdk-for-java/issues/49441: with
azure-spring-data-cosmos on the classpath, OpenFeign must still register a feign.codec.Encoder bean
on Spring Boot 4. See OpenFeignEncoderBeanRegistrationUnitTest. -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>5.0.1</version> <!-- {x-version-update;springboot4_org.springframework.cloud:spring-cloud-starter-openfeign;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -261,6 +275,7 @@
<include>org.springframework:spring-core:[7.0.7]</include> <!-- {x-include-update;springboot4_org.springframework:spring-core;external_dependency} -->
<include>org.springframework:spring-context:[7.0.7]</include> <!-- {x-include-update;springboot4_org.springframework:spring-context;external_dependency} -->
<include>org.springframework.boot:spring-boot-persistence:[4.0.6]</include> <!-- {x-include-update;springboot4_org.springframework.boot:spring-boot-persistence;external_dependency} -->
<include>org.springframework.boot:spring-boot-data-commons:[4.0.6]</include> <!-- {x-include-update;springboot4_org.springframework.boot:spring-boot-data-commons;external_dependency} -->
<include>org.springframework.data:spring-data-commons:[4.0.5]</include> <!-- {x-include-update;springboot4_org.springframework.data:spring-data-commons;external_dependency} -->
<include>org.javatuples:javatuples:[1.2]</include> <!-- {x-include-update;springboot4_org.javatuples:javatuples;external_dependency} -->
<include>com.fasterxml.jackson.core:jackson-annotations:[2.21]</include> <!-- {x-include-update;springboot4_com.fasterxml.jackson.core:jackson-annotations;external_dependency} -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
requires spring.context;
requires spring.core;
requires spring.data.commons;
requires spring.boot.data.commons;
requires spring.expression;
requires spring.tx;
requires spring.web;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.spring.data.cosmos.config;

import feign.codec.Encoder;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.cloud.openfeign.support.PageableSpringEncoder;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Regression test for issue
* <a href="https://github.com/Azure/azure-sdk-for-java/issues/49441">#49441</a>:
* using {@code azure-spring-data-cosmos} together with OpenFeign on Spring Boot 4 failed at startup with
* {@code IllegalStateException: No bean found of type interface feign.codec.Encoder}.
* <p>
* Root cause: OpenFeign's {@code FeignClientsConfiguration} registers an {@link Encoder} via two mutually
* exclusive paths:
* <ul>
* <li>{@code feignEncoder} - guarded by
* {@code @ConditionalOnMissingClass("org.springframework.data.domain.Pageable")}, which is skipped because
* {@code azure-spring-data-cosmos} transitively brings {@code spring-data-commons} (and therefore
* {@code Pageable}) onto the classpath.</li>
* <li>{@code feignEncoderPageable} (in the nested {@code SpringDataConfiguration}) - guarded by
* {@code @ConditionalOnClass({ Pageable.class, DataWebProperties.class })}. In Spring Boot 4
* {@code DataWebProperties} moved from {@code spring-data-commons} to {@code spring-boot-data-commons}, so
* this path was skipped when {@code spring-boot-data-commons} was missing from the classpath.</li>
* </ul>
* With neither path firing, no {@link Encoder} bean was created and the application context failed to start.
* <p>
* The fix adds the {@code spring-boot-data-commons} dependency so that {@code DataWebProperties} is on the
* classpath, allowing the {@code SpringDataConfiguration} path to fire and register a
* {@link PageableSpringEncoder}. This test loads OpenFeign's {@link FeignClientsConfiguration} on the
* {@code azure-spring-data-cosmos} classpath and asserts that the {@link Encoder} bean is present and is a
* {@link PageableSpringEncoder}. If the {@code spring-boot-data-commons} dependency is removed, the
* {@code Encoder} bean disappears and this test fails.
*/
public class OpenFeignEncoderBeanRegistrationUnitTest {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(FeignClientsConfiguration.class);

@Test
public void encoderBeanIsRegistered() {
contextRunner.run(context -> assertThat(context).hasSingleBean(Encoder.class));
}

@Test
public void encoderBeanIsPageableSpringEncoder() {
contextRunner.run(context -> assertThat(context.getBean(Encoder.class)).isInstanceOf(PageableSpringEncoder.class));
}
}
Loading