mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
Only flush Watcher's bulk processor if Watcher is enabled (#38803)
When shutting down Watcher, the `bulkProcessor` is null if watcher has been disabled in the configuration. This protects the flush and close calls with a check for watcher enabled to avoid a NullPointerException Resolves #38798
This commit is contained in:
parent
4ad4bc7f5f
commit
60c1dcde88
@ -669,10 +669,12 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
bulkProcessor.flush();
|
||||
if (enabled) {
|
||||
bulkProcessor.flush();
|
||||
}
|
||||
IOUtils.closeWhileHandlingException(httpClient);
|
||||
try {
|
||||
if (bulkProcessor.awaitClose(10, TimeUnit.SECONDS) == false) {
|
||||
if (enabled && bulkProcessor.awaitClose(10, TimeUnit.SECONDS) == false) {
|
||||
logger.warn("failed to properly close watcher bulk processor");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -81,6 +81,8 @@ public class WatcherPluginTests extends ESTestCase {
|
||||
|
||||
// also no component creation if not enabled
|
||||
assertThat(watcher.createComponents(null, null, null, null, null, null, null, null, null), hasSize(0));
|
||||
|
||||
watcher.close();
|
||||
}
|
||||
|
||||
public void testThreadPoolSize() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user