1616import java .net .http .HttpRequest ;
1717import java .net .http .HttpResponse ;
1818import java .util .*;
19+ import java .util .concurrent .ExecutionException ;
1920
2021@ Slf4j
2122@ Service
2223public class LeetcodeService {
2324
24- public String getProblemWithTagAndDifficulty (String difficulty , String userTag ) throws URISyntaxException , IOException , InterruptedException {
25+ public String getProblemWithTagAndDifficulty (String difficulty , String userTag ) throws URISyntaxException , IOException , InterruptedException , ExecutionException {
2526 List <Problem > problems = getProblemsWithTagAndDifficulty (difficulty , userTag );
2627 if (problems .isEmpty ())
2728 throw new IOException ();
@@ -30,19 +31,19 @@ public String getProblemWithTagAndDifficulty(String difficulty, String userTag)
3031 return "Title: " + randomProblem .title + "\n Link: https://leetcode.com/problems/" + randomProblem .titleSlug ;
3132 }
3233
33- private List <Problem > getProblemsWithTagAndDifficulty (String difficulty , String userTag ) throws URISyntaxException , IOException , InterruptedException {
34+ private List <Problem > getProblemsWithTagAndDifficulty (String difficulty , String userTag ) throws URISyntaxException , IOException , InterruptedException , ExecutionException {
3435 try {
3536 HttpClient client = HttpClient .newHttpClient ();
3637 HttpRequest request = HttpRequest .newBuilder ()
3738 .uri (new URI ("http://leetcode:3000/problems?tags=" + userTag + "&limit=10000" ))
3839 .GET ()
3940 .build ();
4041
41- HttpResponse < String > response = client .send (request , HttpResponse .BodyHandlers .ofString ());
42+ var response = client .sendAsync (request , HttpResponse .BodyHandlers .ofString ());
4243
4344 ObjectMapper objectMapper = new ObjectMapper ();
4445
45- ProblemSet problemset = objectMapper .readValue (response .body (), new TypeReference <>() {});
46+ ProblemSet problemset = objectMapper .readValue (response .get (). body (), new TypeReference <>() {});
4647
4748 List <Problem > problems = new ArrayList <>();
4849 for (Question question : problemset .getProblemsetQuestionList ()) {
0 commit comments