Cloud Native 4 min read

Spring Cloud Alibaba Sentinel v2.2.0: Breaking Changes and Migration Guide

Upgrading from Spring Cloud Alibaba v2.1.0 to v2.2.0 introduces breaking changes in Sentinel integration, including the shift from servlet‑based filters to Spring MVC interceptors, altered request‑origin parsing, default URL interception patterns, and lazy‑loading behavior, with code examples and configuration fixes to ensure smooth migration.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Spring Cloud Alibaba Sentinel v2.2.0: Breaking Changes and Migration Guide

Last week we wrote about the Spring Cloud Alibaba V2.2.0 release. The version v2.2.0 is based on Spring Cloud Hoxton. Below is a summary of the problems encountered when upgrading from Spring Cloud Alibaba v2.1.0 to v2.2.0, mainly related to Sentinel.

Breaking Changes, Not Backward Compatible

Spring Cloud Alibaba Sentinel no longer depends on sentinel-web-servlet but on sentinel-spring-webmvc-adapter, using Spring's Interceptor to intercept resources instead of CommonFilter.

Fallback Strategy Modification

Interface changes for URL block handling.

// Previous version
public class PigxUrlBlockHandler implements UrlBlockHandler {
    @Override
    public void blocked(HttpServletRequest request, HttpServletResponse response, BlockException e) throws IOException {
        // fallback business logic
    }
}

// v2.2.0
public class PigxUrlBlockHandler implements BlockExceptionHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception {
        // fallback business logic
    }
}

Request Parser

Package changes for the request origin parser.

// Old version
import com.alibaba.csp.sentinel.adapter.servlet.callback.RequestOriginParser;
// v2.2.0
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;

// Request parser implementation
public class PigxHeaderRequestOriginParser implements RequestOriginParser {
    private static final String ALLOW = "Allow";

    @Override
    public String parseOrigin(HttpServletRequest request) {
        return request.getHeader(ALLOW);
    }
}

Default Interception of /* Requests

In v2.2.0 the default interceptor rule is /*, meaning only requests with URI '/' or '/a' are processed by Sentinel; the dashboard only shows intercepted resources. A pull request was submitted to modify the default rule.

spring:
  cloud:
    sentinel:
      filter:
        url-patterns: /*

Related source:

SentinelWebAutoConfiguration.addInterceptors()

Default Situation: Spring Boot Admin Shows Some Services as Down

When accessing IP:PORT/actuator/health, Sentinel status appears as down because Sentinel is lazily loaded and does not send a heartbeat to the sentinel‑server at startup, causing SentinelHealthIndicator to report false and Spring Boot Admin to display down.

You can enable eager loading so that the heartbeat is sent during startup:

spring:
  cloud:
    sentinel:
      eager: true

Source code reference: SentinelAutoConfiguration.init(), which uses SPI to load the corresponding business.

Conclusion

The Spring Cloud Alibaba Sentinel module has relatively simple and clear source code; its core is initializing the Sentinel adapter and injecting default fallback implementations.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

migrationcloud-nativesentinelSpring Cloud Alibaba
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.