From c7ecfc173f478d5cc7b1b2ed6a22031d6f0ca97f Mon Sep 17 00:00:00 2001 From: ruhan Date: Fri, 11 Oct 2024 15:10:54 +0800 Subject: [PATCH] Pass the retry error to user side --- .../commonjava/util/gateway/util/WebClientAdapter.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/commonjava/util/gateway/util/WebClientAdapter.java b/src/main/java/org/commonjava/util/gateway/util/WebClientAdapter.java index b807a59..36d41e0 100644 --- a/src/main/java/org/commonjava/util/gateway/util/WebClientAdapter.java +++ b/src/main/java/org/commonjava/util/gateway/util/WebClientAdapter.java @@ -384,6 +384,7 @@ public Response intercept( @NotNull Chain chain ) throws IOException { Request req = chain.request(); Response resp = null; + IOException latestException = null; int tryCounter = 0; do { if ( resp != null ) @@ -417,10 +418,7 @@ public Response intercept( @NotNull Chain chain ) throws IOException } catch( IOException e ) { - if ( tryCounter >= count ) - { - throw e; - } + latestException = e; Span.current().setAttribute( "target.try." + tryCounter + ".error_message", e.getMessage() ); Span.current() @@ -447,7 +445,8 @@ public Response intercept( @NotNull Chain chain ) throws IOException Span.current().setAttribute( "target.retries", tryCounter ); - throw new IOException( "Proxy retry interceptor reached an unexpected fall-through condition!" ); + return new Response.Builder().code( 500 ).message( String.format( + "Proxy retry interceptor reached an unexpected fall-through condition! %s", latestException ) ).build(); } }