File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/main/java/io/digdag/plugin/slack Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1313import okhttp3 .Call ;
1414import okhttp3 .FormBody ;
1515import okhttp3 .Interceptor ;
16+ import okhttp3 .MediaType ;
1617import okhttp3 .OkHttpClient ;
1718import okhttp3 .Request ;
1819import okhttp3 .RequestBody ;
1920import okhttp3 .Response ;
21+ import okhttp3 .ResponseBody ;
2022
2123import java .io .IOException ;
2224import java .util .Arrays ;
25+ import java .util .logging .Logger ;
2326
2427import static java .nio .charset .StandardCharsets .UTF_8 ;
2528
@@ -120,10 +123,13 @@ static class RetryInterceptor implements Interceptor
120123 public Response intercept (Chain chain ) throws IOException
121124 {
122125 Request request = chain .request ();
123- Response response = chain .proceed (request );
126+ // Response response = chain.proceed(request);
127+ Response response = new Response .Builder ().code (503 ).message ("503 Service Unavailable" ).body (ResponseBody .create (MediaType .parse ("application/json; charset=utf-8" ), "{}" )).protocol (okhttp3 .Protocol .HTTP_1_1 ).request (request ).build ();
124128 int retryCount = 0 ;
129+ Logger logger = Logger .getLogger (RetryInterceptor .class .getName ());
125130 while (!response .isSuccessful () && retryCount < MAX_RETRY_COUNT && Arrays .asList (retryHttpStatus ).contains (response .code ())) {
126131 retryCount ++;
132+ logger .info ("Retry count: " + retryCount );
127133
128134 response .close ();
129135 try {
@@ -132,7 +138,8 @@ public Response intercept(Chain chain) throws IOException
132138 e .printStackTrace ();
133139 }
134140 // retry request
135- response = chain .proceed (request );
141+ // response = chain.proceed(request);
142+ response = new Response .Builder ().code (503 ).message ("503 Service Unavailable" ).body (ResponseBody .create (MediaType .parse ("application/json; charset=utf-8" ), "{}" )).protocol (okhttp3 .Protocol .HTTP_1_1 ).request (request ).build ();
136143 }
137144 return response ;
138145 }
You can’t perform that action at this time.
0 commit comments