From a18d0c0909339db37472f9e6c7dff5c65cb75238 Mon Sep 17 00:00:00 2001
From: KOPPIREDDY DURGA PRASAD
<144464542+DurgaPrasad-54@users.noreply.github.com>
Date: Thu, 12 Mar 2026 16:04:35 +0530
Subject: [PATCH 1/3] Cherry-pick health and version API enhancements to
release-3.6.1 (#160)
* feat(health,version): add health and version endpoints
* fix(health): restore interrupt flag when InterruptedException occurs
* fix(health): shutdown executor on destroy and sanitize infra errors in /health
* fix(health): MySQL health check with timeout and sanitize errors
* fix(health): harden advanced MySQL checks and throttle execution
* fix(health): remove unused imports
* fix(health): fux deadlock detection issue
* fix(health): fix deadline timeout issue
* fix(health): scope PROCESSLIST lock-wait check to application DB user
* refactor(health): extract MySQL basic health query into helper method
* fix(health): avoid sharing JDBC connections across threads in advanced MySQL checks
* fix(health): avoid blocking DB I/O under write lock and restore interrupt flag
* fix: add missing close brace
---
pom.xml | 35 +-
.../controller/health/HealthController.java | 84 +++
.../controller/version/VersionController.java | 79 +++
.../mmu/service/health/HealthService.java | 588 ++++++++++++++++++
.../mmu/utils/JwtUserIdValidationFilter.java | 4 +-
.../iemr/mmu/utils/mapper/SecurityConfig.java | 2 +-
6 files changed, 783 insertions(+), 9 deletions(-)
create mode 100644 src/main/java/com/iemr/mmu/controller/health/HealthController.java
create mode 100644 src/main/java/com/iemr/mmu/controller/version/VersionController.java
create mode 100644 src/main/java/com/iemr/mmu/service/health/HealthService.java
diff --git a/pom.xml b/pom.xml
index a15dfc50..e4ae13ff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -255,11 +255,7 @@
org.springframework.session
spring-session-data-redis
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
+
org.jacoco
jacoco-maven-plugin
@@ -292,7 +288,7 @@
- ${artifactId}-${version}
+ ${project.artifactId}-${project.version}
org.apache.maven.plugins
@@ -429,7 +425,6 @@
checkstyle.xml
- UTF-8
true
true
false
@@ -444,6 +439,32 @@
+
+ io.github.git-commit-id
+ git-commit-id-maven-plugin
+ 7.0.0
+
+
+ get-the-git-infos
+
+ revision
+
+ initialize
+
+
+
+ true
+ ${project.build.outputDirectory}/git.properties
+
+ ^git.branch$
+ ^git.commit.id.abbrev$
+ ^git.build.version$
+ ^git.build.time$
+
+ false
+ false
+
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/src/main/java/com/iemr/mmu/controller/health/HealthController.java b/src/main/java/com/iemr/mmu/controller/health/HealthController.java
new file mode 100644
index 00000000..3e43269c
--- /dev/null
+++ b/src/main/java/com/iemr/mmu/controller/health/HealthController.java
@@ -0,0 +1,84 @@
+/*
+* AMRIT – Accessible Medical Records via Integrated Technology
+* Integrated EHR (Electronic Health Records) Solution
+*
+* Copyright (C) "Piramal Swasthya Management and Research Institute"
+*
+* This file is part of AMRIT.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see https://www.gnu.org/licenses/.
+*/
+
+package com.iemr.mmu.controller.health;
+
+import java.time.Instant;
+import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.iemr.mmu.service.health.HealthService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+
+@RestController
+@RequestMapping("/health")
+@Tag(name = "Health Check", description = "APIs for checking infrastructure health status")
+public class HealthController {
+
+ private static final Logger logger = LoggerFactory.getLogger(HealthController.class);
+
+ private final HealthService healthService;
+
+ public HealthController(HealthService healthService) {
+ this.healthService = healthService;
+ }
+
+ @GetMapping
+ @Operation(summary = "Check infrastructure health",
+ description = "Returns the health status of MySQL, Redis, and other configured services")
+ @ApiResponses({
+ @ApiResponse(responseCode = "200", description = "Services are UP or DEGRADED (operational with warnings)"),
+ @ApiResponse(responseCode = "503", description = "One or more critical services are DOWN")
+ })
+ public ResponseEntity