Add cloud-2026-upgrade: step-by-step upgrade of the shop to Spring Boot 4.2.0 / Spring Cloud 2026.0.0, with probes

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4HkWoC7hLzk61vZa8
This commit is contained in:
Claude
2026-12-04 08:21:10 +05:30
parent 3c17b13c3f
commit 2ddc181501
59 changed files with 1669 additions and 0 deletions
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.upgrade</groupId>
<artifactId>probe-gateway-webflux</artifactId>
<version>1.0.0</version>
<!-- The two version numbers are overridden from scripts/probe-gateway.sh, so one source tree runs on every train. -->
<properties>
<boot.version>4.2.0</boot.version>
<cloud.version>2026.0.0</cloud.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId>
<version>${boot.version}</version><type>pom</type><scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId>
<version>${cloud.version}</version><type>pom</type><scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>3.9.0</version>
<executions><execution><phase>package</phase><goals><goal>copy-dependencies</goal></goals></execution></executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,12 @@
package com.ankurm.upgrade;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/** Nothing but the gateway; every route and switch is in application.yml or on the command line. */
@SpringBootApplication
public class GatewayProbeApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayProbeApplication.class, args);
}
}
@@ -0,0 +1,32 @@
server:
port: 8090
spring:
application:
name: probe-gateway-webflux
cloud:
gateway:
server:
webflux:
routes:
- id: headers
uri: http://127.0.0.1:9091
predicates:
- Path=/headers
- id: flaky
uri: http://127.0.0.1:9091
predicates:
- Path=/flaky
filters:
- name: Retry
args:
retries: 3
statuses: INTERNAL_SERVER_ERROR
methods: GET
- id: count
uri: http://127.0.0.1:9091
predicates:
- Path=/count
- id: ws
uri: ws://127.0.0.1:9091
predicates:
- Path=/ws/**
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.upgrade</groupId>
<artifactId>probe-gateway-webmvc</artifactId>
<version>1.0.0</version>
<!-- The two version numbers are overridden from scripts/probe-gateway.sh, so one source tree runs on every train. -->
<properties>
<boot.version>4.2.0</boot.version>
<cloud.version>2026.0.0</cloud.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId>
<version>${boot.version}</version><type>pom</type><scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId>
<version>${cloud.version}</version><type>pom</type><scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway-server-webmvc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>3.9.0</version>
<executions><execution><phase>package</phase><goals><goal>copy-dependencies</goal></goals></execution></executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,12 @@
package com.ankurm.upgrade;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/** Nothing but the gateway; every route and switch is in application.yml or on the command line. */
@SpringBootApplication
public class GatewayProbeApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayProbeApplication.class, args);
}
}
@@ -0,0 +1,14 @@
server:
port: 8090
spring:
application:
name: probe-gateway-webmvc
cloud:
gateway:
server:
webmvc:
routes:
- id: headers
uri: http://127.0.0.1:9091
predicates:
- Path=/headers
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.upgrade</groupId>
<artifactId>probe-openfeign-querymap</artifactId>
<version>1.0.0</version>
<properties>
<boot.version>4.2.0</boot.version>
<cloud.version>2026.0.0</cloud.version>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId>
<version>${boot.version}</version><type>pom</type><scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId>
<version>${cloud.version}</version><type>pom</type><scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webmvc</artifactId></dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>3.9.0</version>
<executions><execution><phase>package</phase><goals><goal>copy-dependencies</goal></goals></execution></executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,49 @@
package com.ankurm.upgrade;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/** Sends a nested object through {@code @SpringQueryMap} to itself and prints the query string that arrived. */
@SpringBootApplication
@EnableFeignClients
public class QueryMapProbeApplication {
public record Price(Integer min, Integer max) { }
public record Filter(String text, Price price, List<String> tags, Map<String, String> attrs) { }
@FeignClient(name = "search", url = "http://localhost:${server.port}")
public interface SearchClient {
@GetMapping("/search")
String search(@SpringQueryMap Filter filter);
}
@RestController
static class Echo {
@GetMapping("/search")
String search(HttpServletRequest request) {
return java.net.URLDecoder.decode(String.valueOf(request.getQueryString()), java.nio.charset.StandardCharsets.UTF_8);
}
}
@Bean
CommandLineRunner run(SearchClient client) {
return args -> {
var filter = new Filter("dock", new Price(10, 200), List.of("usb", "hub"), Map.of("colour", "black"));
System.out.println("RESULT query string received: " + client.search(filter));
};
}
public static void main(String[] args) {
System.exit(SpringApplication.exit(SpringApplication.run(QueryMapProbeApplication.class, args)));
}
}
@@ -0,0 +1 @@
server.port: 8095
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.upgrade</groupId>
<artifactId>probe-preview-demos</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>4.2.0</version><type>pom</type><scope>import</scope></dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2026.0.0</version><type>pom</type><scope>import</scope></dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway-server-webflux</artifactId></dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-monitor</artifactId></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-restclient</artifactId></dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId></dependency>
</dependencies>
<build><plugins><plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>3.9.0</version>
<executions><execution><phase>package</phase><goals><goal>copy-dependencies</goal></goals></execution></executions>
</plugin></plugins></build>
</project>
@@ -0,0 +1,47 @@
package ankurm.sc;
import java.net.InetSocketAddress;
import org.springframework.cloud.gateway.filter.headers.ForwardedHeadersFilter;
import org.springframework.cloud.gateway.filter.headers.XForwardedHeadersFilter;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
/**
* Spring Cloud Gateway: what do the forwarded-header filters emit when the caller is NOT a trusted proxy and
* has sent its own Forwarded / X-Forwarded-For headers? Run on 5.0.3 (GA) and 5.1.0 (Paddington milestone).
*/
public class ForwardedDemo {
static MockServerWebExchange exchange(String remote) {
MockServerHttpRequest request = MockServerHttpRequest.get("http://gateway.example/orders")
.remoteAddress(new InetSocketAddress(remote, 40000))
.header("Forwarded", "for=198.51.100.7;proto=https")
.header("X-Forwarded-For", "198.51.100.7")
.header("X-Forwarded-Proto", "https")
.build();
return MockServerWebExchange.from(request);
}
static void print(String label, HttpHeaders h) {
System.out.println(label);
System.out.println(" Forwarded = " + h.get("Forwarded"));
System.out.println(" X-Forwarded-For = " + h.get("X-Forwarded-For"));
System.out.println(" X-Forwarded-Proto= " + h.get("X-Forwarded-Proto"));
}
public static void main(String[] args) {
// Only 10.0.0.0/8 is trusted. The caller is 203.0.113.9, so its forwarded headers must not be believed.
String trusted = "10\\..*";
ForwardedHeadersFilter forwarded = new ForwardedHeadersFilter(trusted);
XForwardedHeadersFilter xForwarded = new XForwardedHeadersFilter(trusted);
MockServerWebExchange untrusted = exchange("203.0.113.9");
print("== untrusted caller 203.0.113.9: Forwarded filter", forwarded.filter(untrusted.getRequest().getHeaders(), untrusted));
MockServerWebExchange untrusted2 = exchange("203.0.113.9");
print("== untrusted caller 203.0.113.9: X-Forwarded filter", xForwarded.filter(untrusted2.getRequest().getHeaders(), untrusted2));
MockServerWebExchange ok = exchange("10.1.2.3");
print("== trusted caller 10.1.2.3: Forwarded filter", forwarded.filter(ok.getRequest().getHeaders(), ok));
}
}
@@ -0,0 +1,62 @@
package ankurm.sc;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import com.sun.net.httpserver.HttpServer;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.config.monitor.HttpPropertyPathNotifier;
import org.springframework.cloud.config.monitor.MonitorConfigurationProperties;
import org.springframework.web.client.RestClient;
/**
* Spring Cloud Config 5.1.0: what does HttpPropertyPathNotifier send when Config Server sees "orders" changed?
* A JDK HttpServer plays the client application; a stub DiscoveryClient says where it lives.
*/
public class HttpNotifierDemo {
public static void main(String[] args) throws Exception {
List<String> received = new CopyOnWriteArrayList<>();
HttpServer server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
server.createContext("/", ex -> {
received.add(ex.getRequestMethod() + " " + ex.getRequestURI());
ex.sendResponseHeaders(204, -1);
ex.close();
});
server.start();
int port = server.getAddress().getPort();
DefaultServiceInstance defaultPath = new DefaultServiceInstance("i1", "orders", "127.0.0.1", port, false);
DefaultServiceInstance metaPath = new DefaultServiceInstance("i2", "orders", "127.0.0.1", port, false,
Map.of("refresh-endpoint", "/custom/refresh"));
DefaultServiceInstance dead = new DefaultServiceInstance("i3", "orders", "127.0.0.1", 1, false);
DiscoveryClient discovery = new DiscoveryClient() {
public String description() { return "stub"; }
public List<ServiceInstance> getInstances(String id) {
return "orders".equals(id) ? List.of(defaultPath, metaPath, dead) : List.of();
}
public List<String> getServices() { return List.of("orders"); }
};
MonitorConfigurationProperties props = new MonitorConfigurationProperties();
HttpPropertyPathNotifier notifier = new HttpPropertyPathNotifier(discovery, RestClient.builder().build(), props);
System.out.println("== 1. changed applications: orders and ghost");
notifier.notifyApplications(Set.of("orders", "ghost"));
received.stream().sorted().forEach(r -> System.out.println("server received: " + r));
System.out.println("requests received = " + received.size() + " (3 instances registered for orders, one unreachable)");
System.out.println("== 2. override the path per application");
received.clear();
props.getHttp().setEndpoints(Map.of("orders", "/internal/refresh"));
notifier.notifyApplications(Set.of("orders"));
received.stream().sorted().forEach(r -> System.out.println("server received: " + r));
server.stop(0);
}
}
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.upgrade</groupId>
<artifactId>probe-reactor-extra</artifactId>
<version>1.0.0</version>
<properties>
<boot.version>4.2.0</boot.version>
<cloud.version>2026.0.0</cloud.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId>
<version>${boot.version}</version><type>pom</type><scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId>
<version>${cloud.version}</version><type>pom</type><scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Only the load balancer starter. The code below uses a class this project never declared. -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency>
</dependencies>
</project>
@@ -0,0 +1,10 @@
package com.ankurm.upgrade;
import reactor.retry.Repeat;
/** Compiles on 2025.1.x only because spring-cloud-loadbalancer happened to pull reactor-extra in. */
public class UsesReactorExtra {
public Object repeatThreeTimes() {
return Repeat.times(3);
}
}