2929@ Slf4j
3030@ Component
3131public class CommonSpringWebClient {
32- private final WebClient webClient ;
32+ private final WebClient webClient ;
3333
3434 public CommonSpringWebClient (@ Qualifier ("RWebPulseClient" ) WebClient webClient ) {
3535 this .webClient = webClient ;
3636 }
3737
3838 /**
39- * Execute Blocking http request.
40- * @param httpRequest
41- * @return
42- * @param <REQUEST>
43- * @param <RESPONSE>
44- */
45- public <REQUEST , RESPONSE > ClientHttpResponse <RESPONSE > syncHttpResponse (ClientHttpRequest <REQUEST , RESPONSE > httpRequest ) {
39+ * Execute Blocking http request.
40+ * @param httpRequest
41+ * @return
42+ * @param <REQUEST>
43+ * @param <RESPONSE>
44+ */
45+ public <REQUEST , RESPONSE > ClientHttpResponse <RESPONSE > syncHttpResponse (ClientHttpRequest <REQUEST , RESPONSE > httpRequest ) {
4646 try {
4747 log .info ("Executing http request for request={}, method={}" , httpRequest .getRequest (),
4848 httpRequest .getHttpMethod ());
@@ -73,9 +73,9 @@ public <REQUEST, RESPONSE> ClientHttpResponse<RESPONSE> syncHttpResponse(ClientH
7373 }
7474 }
7575
76- /**
76+ /**
7777 * Generate Web Client Response spec from http request.
78- *
78+ *
7979 * @param httpRequest
8080 * @return
8181 */
@@ -96,11 +96,11 @@ private <REQUEST, RESPONSE> WebClient.ResponseSpec generateResponseSpec(
9696
9797 }
9898
99- /**
100- * Generates retry spec for the request based on config provided.
101- * @param httpRequest
102- * @return
103- */
99+ /**
100+ * Generates retry spec for the request based on config provided.
101+ * @param httpRequest
102+ * @return
103+ */
104104 private <REQUEST , RESPONSE > Retry generateRetrySpec (ClientHttpRequest <REQUEST , RESPONSE > httpRequest ) {
105105 return Retry
106106 .fixedDelay (httpRequest .getClientRetryConfig ().getMaxAttempts (),
@@ -112,7 +112,7 @@ private <REQUEST, RESPONSE> Retry generateRetrySpec(ClientHttpRequest<REQUEST, R
112112
113113 /**
114114 * Handle Success response.
115- *
115+ *
116116 * @param response
117117 * @return
118118 * @param <RESPONSE>
@@ -122,24 +122,24 @@ private <RESPONSE> ClientHttpResponse<RESPONSE> generateResponse(ResponseEntity<
122122 .isSuccess2xx (response .getStatusCode ().is2xxSuccessful ()).build ();
123123 }
124124
125- /**
126- * Handle Exception and send back response.
127- * @param exception
128- * @param errorMessage
129- * @param httpStatus
130- * @param httpRequest
131- * @return
132- * @param <RESPONSE>
133- */
134- private <REQUEST , RESPONSE > ClientHttpResponse <RESPONSE > handleException (
135- final Exception exception ,
136- final String errorMessage ,
137- final String responseBody ,
138- final HttpStatus httpStatus ,
139- final ClientHttpRequest <REQUEST , RESPONSE > httpRequest ) {
140- log .error ("Exception while executing http request for requestUrl={}, status={}, errorMessage={}" , httpRequest .getUrl (), httpStatus , errorMessage );
141- httpRequest .getRetryHandlers ()
142- .forEach (handlerId -> RetryHandlerFactory .getHandler (handlerId .toString ()).checkAndThrowRetriableException (exception ));
143- return ClientHttpResponse .<RESPONSE >builder ().error (responseBody ).status (httpStatus ).build ();
144- }
125+ /**
126+ * Handle Exception and send back response.
127+ * @param exception
128+ * @param errorMessage
129+ * @param httpStatus
130+ * @param httpRequest
131+ * @return
132+ * @param <RESPONSE>
133+ */
134+ private <REQUEST , RESPONSE > ClientHttpResponse <RESPONSE > handleException (
135+ final Exception exception ,
136+ final String errorMessage ,
137+ final String responseBody ,
138+ final HttpStatus httpStatus ,
139+ final ClientHttpRequest <REQUEST , RESPONSE > httpRequest ) {
140+ log .error ("Exception while executing http request for requestUrl={}, status={}, errorMessage={}" , httpRequest .getUrl (), httpStatus , errorMessage );
141+ httpRequest .getRetryHandlers ()
142+ .forEach (handlerId -> RetryHandlerFactory .getHandler (handlerId .toString ()).checkAndThrowRetriableException (exception ));
143+ return ClientHttpResponse .<RESPONSE >builder ().error (responseBody ).status (httpStatus ).build ();
144+ }
145145}
0 commit comments