• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 29365517473

14 Jul 2026 08:23PM UTC coverage: 63.813% (+0.04%) from 63.775%
29365517473

push

github

web-flow
TRUNK-6675: Module is not updated when omod changes (#6257)

* TRUNK-6675: Module is not updated when omod changes

* TRUNK-6675: Address review comments

- Split the deleteDirectory try-catch in the optimized-startup branch so IOException from deletion logs an accurate message instead of "Error while reading module last modified file"
- Pin getLibCacheFolderForModule_shouldRecreateNonEmptyDirWhenModuleChanged to the module-changed branch by explicitly setting optimized.startup=true

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* TRUNK-6675: Address review comments

- Extract deleteLibCacheDir helper to reduce cognitive complexity (fixes SonarCloud quality gate)
- Guard .moduleLastModified write on successful deletion so a failed delete does not mask the problem on the next restart
- Fix Context.getRuntimeProperties() defensive-copy bug in both tests: mutate the copy and push it back via Context.setRuntimeProperties() so isOptimizedStartup() actually sees the change

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Update api/src/main/java/org/openmrs/module/ModuleClassLoader.java

Co-authored-by: dkayiwa <dkayiwa@openmrs.org>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: dkayiwa <dkayiwa@openmrs.org>

7 of 11 new or added lines in 1 file covered. (63.64%)

21 existing lines in 8 files now uncovered.

24094 of 37757 relevant lines covered (63.81%)

0.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.0
/api/src/main/java/org/openmrs/scheduler/jobrunr/JobRequestHandlerAdapter.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs.scheduler.jobrunr;
11

12
import java.util.Map;
13

14
import org.jobrunr.JobRunrException;
15
import org.openmrs.api.context.Daemon;
16
import org.openmrs.scheduler.TaskContext;
17
import org.openmrs.scheduler.TaskData;
18
import org.openmrs.scheduler.TaskException;
19
import org.openmrs.scheduler.TaskHandler;
20
import org.springframework.context.ApplicationContext;
21
import org.springframework.context.ApplicationContextAware;
22
import org.springframework.core.GenericTypeResolver;
23
import org.springframework.stereotype.Component;
24

25
/**
26
 * A generic handler that delegates execution to the appropriate {@link TaskHandler}.
27
 * 
28
 * @since 2.9.0
29
 */
30
@Component
31
public class JobRequestHandlerAdapter implements org.jobrunr.jobs.lambdas.JobRequestHandler<JobRequestAdapter>, ApplicationContextAware {
1✔
32
        
33
        private ApplicationContext applicationContext;
34

35
        @Override
36
        public void setApplicationContext(ApplicationContext applicationContext) {
37
                this.applicationContext = applicationContext;
1✔
38
        }
1✔
39

40
        @SuppressWarnings("unchecked")
41
        @Override
42
        public void run(JobRequestAdapter jobRequestAdapter) throws Exception {
UNCOV
43
                TaskData request = jobRequestAdapter.getJobRequest();
×
UNCOV
44
                TaskContext context = new JobRunrTaskContext(jobContext(), jobRequestAdapter.getUserSystemId());
×
UNCOV
45
                Map<String, TaskHandler> handlers = applicationContext.getBeansOfType(TaskHandler.class);
×
46

UNCOV
47
                for (TaskHandler handler : handlers.values()) {
×
UNCOV
48
                        Class<?> genericType = GenericTypeResolver.resolveTypeArgument(handler.getClass(), TaskHandler.class);
×
UNCOV
49
                        if (genericType != null && genericType.isAssignableFrom(request.getClass())) {
×
50
                                Daemon.executeScheduledTaskAsUser(jobRequestAdapter.getUserSystemId(), () -> {
×
51
                                        try {
52
                                                handler.execute(request, context);
×
53
                                        } catch (TaskException e) {
×
54
                                                if (e.isDoNotRetry()) {
×
55
                                                        throw new JobRunrException(e.getMessage(), e.isDoNotRetry(), e);
×
56
                                                } else {
57
                                                        throw e;
×
58
                                                }
59
                                        }
×
60
                                });
×
61
                                return;
×
62
                        }
UNCOV
63
                }
×
64
                throw new IllegalStateException("No handler found for " + request.getClass().getName());
×
65
        }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc