Lazy load executor so that tests work safely.
@@ -174,6 +174,9 @@ public abstract class BaseTransactionProcessor {
@PostConstruct
public void start() {
ourLog.trace("Starting transaction processor");
+ }
+ public TaskExecutor getTaskExecutor() {
+ if (myExecutor == null) {
if (myDaoConfig.getBundleBatchPoolSize() > 1) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("bundle_batch_");
@@ -188,6 +191,8 @@ public abstract class BaseTransactionProcessor {
myExecutor = executor;
}
}
+ return myExecutor;
+ }
public <BUNDLE extends IBaseBundle> BUNDLE transaction(RequestDetails theRequestDetails, BUNDLE theRequest, boolean theNestedMode) {
if (theRequestDetails != null && theRequestDetails.getServer() != null && myDao != null) {
@@ -354,7 +359,7 @@ public abstract class BaseTransactionProcessor {
for (int i=0; i<requestEntriesSize; i++ ) {
nextRequestEntry = requestEntries.get(i);
BundleTask bundleTask = new BundleTask(completionLatch, theRequestDetails, responseMap, i, nextRequestEntry, theNestedMode);
- myExecutor.execute(bundleTask);
+ getTaskExecutor().execute(bundleTask);
}
// waiting for all tasks to be completed
