From 1edf2f15d823bc4bf81487cceec01a347e1c11fb Mon Sep 17 00:00:00 2001 From: Asaf Chen <109060156+asafchen-dig@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:58:24 -0400 Subject: [PATCH 1/2] feat: configure hikari connection pool settings and retry params --- src/main/resources/application.properties | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f7aef094b4f..1032904d1ac 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -13,7 +13,16 @@ spring.thymeleaf.mode=HTML spring.jpa.hibernate.ddl-auto=none spring.jpa.open-in-view=true -# FlaskDb +# Connection pool settings +spring.datasource.hikari.maximum-pool-size=10 +spring.datasource.hikari.minimum-idle=5 +spring.datasource.hikari.idle-timeout=300000 +spring.datasource.hikari.connection-timeout=20000 +spring.datasource.hikari.max-lifetime=1200000 + +# Retry configuration +spring.datasource.hikari.connection-retry-attempts=3 +spring.datasource.hikari.connection-retry-delay=1000# FlaskDb spring.data.flaskdb.uri=http://localhost:27017/feedbacks # Internationalization From 705117d6552c16a42baea0878fae6b00c25bfa55 Mon Sep 17 00:00:00 2001 From: Asaf Chen <109060156+asafchen-dig@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:59:57 -0400 Subject: [PATCH 2/2] feat: enhance FeedbackController with ResponseEntity and error handling --- .../clinicfeedback/FeedbackController.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/clinicfeedback/FeedbackController.java b/src/main/java/org/springframework/samples/petclinic/clinicfeedback/FeedbackController.java index 1b872becfdc..9fe0253ca53 100644 --- a/src/main/java/org/springframework/samples/petclinic/clinicfeedback/FeedbackController.java +++ b/src/main/java/org/springframework/samples/petclinic/clinicfeedback/FeedbackController.java @@ -7,14 +7,18 @@ import org.springframework.samples.petclinic.owner.Owner; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; @RestController -@RequestMapping("/api/clinic-feedback") -public class FeedbackController { +@RequestMapping("/api/clinic-feedback")public class FeedbackController { private final FeedbackService service; + private static final Logger log = LoggerFactory.getLogger(FeedbackController.class); public FeedbackController(FeedbackService service) { this.service = service; @@ -29,9 +33,15 @@ public List list( return results; } - @GetMapping("count") - public String count() { - return String.valueOf(service.count()); + @GetMapping(value = "/count", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity count() { + try { + long count = this.service.count(); + return ResponseEntity.ok().body(count); + } catch (Exception e) { + log.error("Error retrieving feedback count", e); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); + } } @PostMapping("clear") @@ -51,8 +61,7 @@ public ResponseEntity populateFeedbacks(@RequestParam(name = "count", de return ResponseEntity.internalServerError().body(ex.getMessage()); } } - - @PostMapping("add") +}@PostMapping("add") public ResponseEntity addFeedback(@RequestBody ClinicFeedback newFeedback, BindingResult result) { if(result.hasErrors()) return ResponseEntity.badRequest().body("Failed to parsed request"); @@ -67,4 +76,4 @@ public ResponseEntity addFeedback(@RequestBody ClinicFeedback newFeedbac } } -} +} \ No newline at end of file