Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 16c2c6a

Browse files
author
Rob Rudin
committed
Ensuring taskExecutor is set to null so it can be re-initialized, and not performing a write if there are no schemas to load
1 parent 8b6ff17 commit 16c2c6a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/com/marklogic/client/modulesloader/impl/DefaultModulesLoader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@ protected void waitForTaskExecutorToFinish() {
143143
if (shutdownTaskExecutorAfterLoadingModules) {
144144
if (taskExecutor instanceof ExecutorConfigurationSupport) {
145145
((ExecutorConfigurationSupport) taskExecutor).shutdown();
146+
taskExecutor = null;
146147
} else if (taskExecutor instanceof DisposableBean) {
147148
try {
148149
((DisposableBean) taskExecutor).destroy();
149150
} catch (Exception ex) {
150151
logger.warn("Unexpected exception while calling destroy() on taskExecutor: " + ex.getMessage(), ex);
151152
}
153+
taskExecutor = null;
152154
}
153155
} else if (logger.isDebugEnabled()) {
154156
logger.debug("shutdownTaskExecutorAfterLoadingModules is set to false, so not shutting down taskExecutor");

src/main/java/com/marklogic/client/schemasloader/impl/DefaultSchemasLoader.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,25 @@ public DefaultSchemasLoader(DocumentFileReader documentFileReader, BatchWriter b
7171
*/
7272
@Override
7373
public List<DocumentFile> loadSchemas(String... paths) {
74-
try {
75-
List<DocumentFile> documentFiles = documentFileReader.readDocumentFiles(paths);
74+
List<DocumentFile> documentFiles = documentFileReader.readDocumentFiles(paths);
75+
if (documentFiles != null && !documentFiles.isEmpty()) {
76+
if (logger.isInfoEnabled()) {
77+
logger.info(format("Writing %d files into the schemas database", documentFiles.size()));
78+
}
7679
batchWriter.write(documentFiles);
77-
return documentFiles;
78-
} finally {
7980
if (waitForCompletion) {
8081
batchWriter.waitForCompletion();
8182
}
8283
}
84+
return documentFiles;
8385
}
8486

8587
/**
86-
* @deprecated
8788
* @param baseDir
8889
* @param schemasDataFinder
8990
* @param client
9091
* @return
92+
* @deprecated
9193
*/
9294
@Override
9395
public Set<File> loadSchemas(File baseDir, SchemasFinder schemasDataFinder, DatabaseClient client) {

0 commit comments

Comments
 (0)