Skip to content

Commit 09069e5

Browse files
committed
use dedicated method to shutdown search executor
also shut it down in webapp
1 parent bcc17c6 commit 09069e5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ private ExecutorService newSearchExecutor() {
203203
});
204204
}
205205

206+
public void shutdownSearchExecutor() {
207+
getSearchExecutor().shutdownNow();
208+
try {
209+
getSearchExecutor().awaitTermination(getIndexerCommandTimeout(), TimeUnit.SECONDS);
210+
} catch (InterruptedException e) {
211+
LOGGER.log(Level.WARNING, "failed to await shutdown of search executor", e);
212+
}
213+
}
214+
206215
public ExecutorService getRevisionExecutor() {
207216
return lzRevisionExecutor.get();
208217
}

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public static void main(String[] argv) {
413413
System.err.println("Exception: " + e.getLocalizedMessage());
414414
System.exit(1);
415415
} finally {
416-
env.getSearchExecutor().shutdownNow();
416+
env.shutdownSearchExecutor();
417417
stats.report(LOGGER, "Indexer finished", "indexer.total");
418418
}
419419
}

opengrok-web/src/main/java/org/opengrok/web/WebappListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2018, 2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.web;
@@ -167,6 +167,7 @@ public void contextDestroyed(final ServletContextEvent servletContextEvent) {
167167
env.stopExpirationTimer();
168168
try {
169169
env.shutdownRevisionExecutor();
170+
env.shutdownSearchExecutor();
170171
} catch (InterruptedException e) {
171172
LOGGER.log(Level.WARNING, "Could not shutdown revision executor", e);
172173
}

0 commit comments

Comments
 (0)