Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
<server-hostname>{hostname-${environment}}</server-hostname>
<server-port>{port-${environment}}</server-port>
</properties>

<repositories>
<repository>
<id>openkm.com</id>
<name>OpenKM Maven Repository</name>
<url>https://maven.openkm.com</url>
</repository>
</repositories>

<dependencies>

<dependency>
Expand Down Expand Up @@ -204,13 +205,15 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.17.0</version>

</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>

<groupId>com.openkm</groupId>
<artifactId>sdk4j</artifactId>
<version>1.0</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,22 @@ public class ScheduleJobForNHMDashboardData implements Job {
@Autowired
private NHM_DashboardService nhmDashboardService;

@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
logger.info("Started job for NHM dashboard data pull from cti " + arg0.getClass().getName());
try {
String s = nhmDashboardService.pull_NHM_Data_CTI();
logger.info(s);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
}
logger.info("Completed job for NHM dashboard data pull from cti " + arg0.getClass().getName());
}
}
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {

logger.info("Started job for NHM dashboard data pull from cti " + arg0.getClass().getName());

if (nhmDashboardService == null) {
logger.error("NHM_DashboardService bean is not initialized. Skipping execution.");
return;
}

try {
String s = nhmDashboardService.pull_NHM_Data_CTI();
logger.info(s);
} catch (Exception e) {
logger.error("Error while pulling NHM dashboard data", e);
}

logger.info("Completed job for NHM dashboard data pull from cti " + arg0.getClass().getName());
Comment on lines +55 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Quartz Scheduler Job execute method exception handling if exception caught and not thrown

💡 Result:

If your Quartz Job.execute(...) catches an exception and does not rethrow it, Quartz treats that run as successful: the trigger is considered “completed normally,” the scheduler won’t refire/unschedule based on that failure, and the job will simply run again at its next scheduled fire time. (Quartz only reacts when something escapes execute, especially a JobExecutionException.) [3], [4]

If you want Quartz to know the run failed and optionally take action, rethrow a JobExecutionException:

  • Keep normal schedule (no immediate refire, no unschedule): throw new JobExecutionException(cause) with no flags (it records the failure; next fire proceeds normally). [2], [5]
  • Refire immediately: new JobExecutionException(cause, refireImmediately: true) (Quartz.NET example shown; same concept in Java). [1], [2]
  • Unschedule triggers / stop future runs: set setUnscheduleAllTriggers(true) (Java example). [6], [2]

So: catch-and-swallow = Quartz won’t do anything special; catch-and-throw JobExecutionException = Quartz can apply retry/unschedule directives. [2], [6]


🏁 Script executed:

find . -name "ScheduleJobForNHMDashboardData.java" -type f

Repository: PSMRI/Common-API

Length of output: 141


🏁 Script executed:

cat -n ./src/main/java/com/iemr/common/config/quartz/ScheduleJobForNHMDashboardData.java

Repository: PSMRI/Common-API

Length of output: 2757


Propagate job failures to Quartz instead of suppressing them.

Exceptions caught at lines 58–60 are logged but not re-thrown. Quartz treats this as a successful job execution (exceptions only matter to Quartz when JobExecutionException escapes execute()). Additionally, line 62 unconditionally logs completion even after a failure, obscuring actual failures in logs and monitoring.

Move the completion log into the try block and throw JobExecutionException on exception:

Proposed fix
 public void execute(JobExecutionContext arg0) throws JobExecutionException {

     logger.info("Started job for NHM dashboard data pull from cti " + arg0.getClass().getName());

     if (nhmDashboardService == null) {
         logger.error("NHM_DashboardService bean is not initialized. Skipping execution.");
         return;
     }

     try {
         String s = nhmDashboardService.pull_NHM_Data_CTI();
         logger.info(s);
+        logger.info("Completed job for NHM dashboard data pull from cti " + arg0.getClass().getName());
     } catch (Exception e) {
         logger.error("Error while pulling NHM dashboard data", e);
-    }
-
-    logger.info("Completed job for NHM dashboard data pull from cti " + arg0.getClass().getName());
+        throw new JobExecutionException("Error while pulling NHM dashboard data", e, false);
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/iemr/common/config/quartz/ScheduleJobForNHMDashboardData.java`
around lines 55 - 62, The catch block in ScheduleJobForNHMDashboardData
currently swallows exceptions from nhmDashboardService.pull_NHM_Data_CTI() and
always logs completion; change it to rethrow a Quartz JobExecutionException so
Quartz sees failures: move the "Completed job..." logger into the try block
(after nhmDashboardService.pull_NHM_Data_CTI() and logger.info(s)), and in the
catch(Exception e) throw new JobExecutionException("Error pulling NHM dashboard
data for " + arg0.getClass().getName(), e, false) (or true if you want retry) so
the failure is propagated to Quartz.

}