Skip to content

Compatibility issues with Spring Boot 4 / Spring Framework 6.2+ #1466

@mingchiuli

Description

@mingchiuli

Issue Description

The Brave library has compatibility issues with Spring Boot 4 (which uses Spring Framework 6.2+). Specifically, the brave.spring.web.TracingClientHttpRequestInterceptor class uses deprecated/removed APIs that no longer exist in the latest Spring Framework versions.

Environment

  • Brave version: brave-instrumentation-spring-web:6.3.0 (and potentially other recent versions)
  • Spring Boot version: 4.x
  • Spring Framework version: 6.2.x
  • Java version: [Your Java version]

Problem Details

1. Missing getRawStatusCode() method

The ClientHttpResponse interface in Spring Framework 6.2+ no longer includes the getRawStatusCode() method.

Current code in TracingClientHttpRequestInterceptor.java (line 129):

int result = response != null ? response.getRawStatusCode() : 0;

Issue: The ClientHttpResponse interface now only provides:

  • HttpStatusCode getStatusCode() - returns an HttpStatusCode object instead of a raw int
  • String getStatusText()

Reference: [Spring Framework ClientHttpResponse interface](https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java)

2. Type compatibility issues with request wrapper

There appear to be additional type incompatibilities with the HttpRequestWrapper class used in the interceptor, though the specific details need further investigation.

Expected Behavior

The Brave instrumentation should work seamlessly with Spring Boot 4 / Spring Framework 6.2+ without compilation errors.

Proposed Solution

Update the TracingClientHttpRequestInterceptor class to use the new Spring Framework 6.2+ APIs:

// Instead of:
int result = response != null ? response.getRawStatusCode() : 0;

// Use:
int result = response != null ? response.getStatusCode().value() : 0;

Steps to Reproduce

  1. Create a Spring Boot 4 project with the following dependency:
<dependency>
    <groupId>io.zipkin.brave</groupId>
    <artifactId>brave-instrumentation-spring-web</artifactId>
    <version>6.3.0</version>
</dependency>
  1. Try to compile the project
  2. Observe compilation errors related to missing methods

Additional Context

This issue affects anyone trying to upgrade to Spring Boot 4 while using Brave for distributed tracing. The changes in Spring Framework 6.2 removed several deprecated methods, requiring updates to third-party libraries.

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions