From 3c17b13c3f6ddc3daff78cd5144848154118c870 Mon Sep 17 00:00:00 2001 From: asmhatre Date: Thu, 26 Nov 2026 00:56:43 +0530 Subject: [PATCH] gateway-mvc: add transcript for the wrong Spring Retry import Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_017ic4b3W3uHbHAmM3orhn7b --- gateway-mvc/README.md | 1 + gateway-mvc/output/07-wrong-retry-import.txt | 5 +++++ gateway-mvc/scripts/wrong-retry-import.sh | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 gateway-mvc/output/07-wrong-retry-import.txt create mode 100755 gateway-mvc/scripts/wrong-retry-import.sh diff --git a/gateway-mvc/README.md b/gateway-mvc/README.md index 62aa92a..8791086 100644 --- a/gateway-mvc/README.md +++ b/gateway-mvc/README.md @@ -12,6 +12,7 @@ The walkthrough lives in the blog post; everything quoted there comes from `outp | `src/main/resources/application.yml` | the YAML flavour of a route, Tomcat limited to 10 threads, virtual threads on, `platform` profile | | `scripts/Upstream.java` | a dependency-free backend: `/hello`, `/limited`, `/slow`, `/flaky`, `/headers` | | `scripts/LoadClient.java` | fires N concurrent requests and prints a status summary and elapsed time | +| `scripts/wrong-retry-import.sh` | reproduces the `NoClassDefFoundError` you get from importing the Spring Retry flavour of `retry()` without Spring Retry | | `scripts/run-all.sh` | rebuilds and regenerates every file in `output/` (needs JDK 25, Maven, `redis-server`) | ```bash diff --git a/gateway-mvc/output/07-wrong-retry-import.txt b/gateway-mvc/output/07-wrong-retry-import.txt new file mode 100644 index 0000000..c97daf3 --- /dev/null +++ b/gateway-mvc/output/07-wrong-retry-import.txt @@ -0,0 +1,5 @@ +# the one-line change in a temporary copy of RoutesConfig.java +8:import static org.springframework.cloud.gateway.server.mvc.filter.GatewayRetryFilterFunctions.retry; +# startup log: +Factory method 'retryRoute' threw exception with message: org/springframework/retry/RetryPolicy +Caused by: java.lang.NoClassDefFoundError: org/springframework/retry/RetryPolicy diff --git a/gateway-mvc/scripts/wrong-retry-import.sh b/gateway-mvc/scripts/wrong-retry-import.sh new file mode 100755 index 0000000..1e90393 --- /dev/null +++ b/gateway-mvc/scripts/wrong-retry-import.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Shows what happens if RoutesConfig imports GatewayRetryFilterFunctions.retry (the Spring Retry flavour) +# instead of RetryFilterFunctions.retry (the one that picks an implementation). Works on a temporary copy. +set -u +. "$(dirname "$0")/lib.sh" +TMP="$(mktemp -d)"; cp -r "$HERE/pom.xml" "$HERE/src" "$TMP/" +sed -i 's/filter\.RetryFilterFunctions\.retry/filter.GatewayRetryFilterFunctions.retry/' "$TMP/src/main/java/com/ankurm/gwmvc/RoutesConfig.java" +echo "\$ diff: the one-line change" +grep -n 'RetryFilterFunctions.retry' "$TMP/src/main/java/com/ankurm/gwmvc/RoutesConfig.java" +(cd "$TMP" && mvn -B -q -DskipTests package 2>&1 | grep -E 'ERROR|BUILD' | head -3) +stop_all +java -jar "$TMP/target/gateway-mvc-1.0.0.jar" --server.port=8099 > "$LOGDIR/wrong-import.log" 2>&1 +echo "# startup log:" +grep -m1 -oE 'Factory method .retryRoute. threw exception with message: [^ ]+' "$LOGDIR/wrong-import.log" +grep -m1 'Caused by: java.lang.NoClassDefFoundError' "$LOGDIR/wrong-import.log" +rm -rf "$TMP"