33import cf .maybelambda .httpvalidator .springboot .model .ValidationTask ;
44import cf .maybelambda .httpvalidator .springboot .persistence .XMLValidationTaskDao ;
55import cf .maybelambda .httpvalidator .springboot .util .HttpSendOutcomeWrapper ;
6- import com .fasterxml .jackson .core .JsonProcessingException ;
7- import com .fasterxml .jackson .databind .ObjectMapper ;
86import org .slf4j .Logger ;
97import org .slf4j .LoggerFactory ;
108import org .springframework .beans .factory .annotation .Autowired ;
119import org .springframework .core .env .Environment ;
1210import org .springframework .scheduling .annotation .Scheduled ;
1311import org .springframework .scheduling .support .CronExpression ;
1412import org .springframework .stereotype .Service ;
13+ import tools .jackson .core .JacksonException ;
14+ import tools .jackson .databind .ObjectMapper ;
1515
1616import javax .management .modelmbean .XMLParseException ;
1717import java .io .FileNotFoundException ;
@@ -70,8 +70,8 @@ public class ValidationService {
7070 */
7171 public ValidationService () {
7272 this .client = HttpClient .newBuilder ()
73- .connectTimeout (CONNECT_TIMEOUT_SECONDS )
74- .followRedirects (HttpClient .Redirect .ALWAYS ).build ();
73+ .connectTimeout (CONNECT_TIMEOUT_SECONDS )
74+ .followRedirects (HttpClient .Redirect .ALWAYS ).build ();
7575 }
7676
7777 /**
@@ -82,13 +82,13 @@ public ValidationService() {
8282 *
8383 * @throws FileNotFoundException if the data file is not found
8484 * @throws XMLParseException if there is an error parsing the XML file
85- * @throws JsonProcessingException when a validation task contains invalid JSON content
85+ * @throws JacksonException when a validation task contains invalid JSON content
8686 * @throws ConnectIOException if there is an error sending notification email
8787 * @throws ExecutionException when an unhandled error occurs while processing the HTTP requests
8888 * @throws InterruptedException when interrupted before completing all the requests
8989 */
9090 @ Scheduled (cron = "${" + RUN_SCHEDULE_PROPERTY + "}" )
91- public void execValidations () throws FileNotFoundException , XMLParseException , JsonProcessingException ,
91+ public void execValidations () throws FileNotFoundException , XMLParseException , JacksonException ,
9292 ConnectIOException , ExecutionException , InterruptedException {
9393 // Record the start date-time of the validation process
9494 Instant start = Instant .now ();
@@ -113,9 +113,9 @@ public void execValidations() throws FileNotFoundException, XMLParseException, J
113113 * @return a list of HttpSendOutcomeWrapper objects containing the responses or exceptions
114114 * @throws ExecutionException when an unhandled error occurs while processing the HTTP requests
115115 * @throws InterruptedException when interrupted before completing all the requests
116- * @throws JsonProcessingException when a validation task contains invalid JSON content
116+ * @throws JacksonException when a validation task contains invalid JSON content
117117 */
118- List <HttpSendOutcomeWrapper > buildAndExecuteRequests (List <ValidationTask > tasks ) throws ExecutionException , InterruptedException , JsonProcessingException {
118+ List <HttpSendOutcomeWrapper > buildAndExecuteRequests (List <ValidationTask > tasks ) throws ExecutionException , InterruptedException , JacksonException {
119119 // Build HTTP requests from the validation tasks
120120 List <HttpRequest > reqs = new ArrayList <>();
121121 for (ValidationTask task : tasks ) {
@@ -134,13 +134,13 @@ List<HttpSendOutcomeWrapper> buildAndExecuteRequests(List<ValidationTask> tasks)
134134 // Send the requests asynchronously and store the responses or exceptions in the results list
135135 // Use the index of each request to store the corresponding response or exception
136136 List <CompletableFuture <Void >> futures = IntStream .range (0 , reqs .size ())
137- .mapToObj (i -> client .sendAsync (reqs .get (i ), HttpResponse .BodyHandlers .ofString ())
138- .thenAccept (res -> results .set (i , new HttpSendOutcomeWrapper (res )))
139- .exceptionally (e -> {
140- results .set (i , new HttpSendOutcomeWrapper (e ));
141- return null ;
142- }))
143- .toList ();
137+ .mapToObj (i -> client .sendAsync (reqs .get (i ), HttpResponse .BodyHandlers .ofString ())
138+ .thenAccept (res -> results .set (i , new HttpSendOutcomeWrapper (res )))
139+ .exceptionally (e -> {
140+ results .set (i , new HttpSendOutcomeWrapper (e ));
141+ return null ;
142+ }))
143+ .toList ();
144144 // Wait for all requests to complete
145145 CompletableFuture .allOf (futures .toArray (new CompletableFuture [0 ])).get ();
146146
0 commit comments