Skip to content

Commit 80cd321

Browse files
committed
fix: also close handler and wait a little for tasks to finish
1 parent 8ab0c33 commit 80cd321

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Optional;
2323
import java.util.Set;
2424
import java.util.concurrent.ScheduledThreadPoolExecutor;
25+
import java.util.concurrent.TimeUnit;
2526
import java.util.concurrent.locks.ReentrantLock;
2627
import org.slf4j.Logger;
2728
import org.slf4j.LoggerFactory;
@@ -75,12 +76,12 @@ public DefaultEventHandler(
7576

7677
@Override
7778
public void close() {
78-
if (eventSourceManager != null) {
79-
log.debug("Closing EventSourceManager {} -> {}", controllerName, eventSourceManager);
80-
eventSourceManager.close();
79+
try {
80+
log.debug("Closing handler for {}", controllerName);
81+
executor.awaitTermination(10, TimeUnit.SECONDS);
82+
} catch (InterruptedException e) {
83+
log.debug("Exception closing handler for {}: {}", controllerName, e.getLocalizedMessage());
8184
}
82-
83-
executor.shutdownNow();
8485
}
8586

8687
public void setEventSourceManager(DefaultEventSourceManager eventSourceManager) {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/CustomResourceEventSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public void start() {
7979

8080
@Override
8181
public void close() {
82+
eventHandler.close();
8283
for (Watch watch : this.watches) {
8384
try {
84-
log.debug("Closing watch {} -> {}", resClass, watch);
85+
log.info("Closing watch {} -> {}", resClass, watch);
8586
watch.close();
8687
} catch (Exception e) {
8788
log.warn("Error closing watcher {} -> {}", resClass, watch, e);

0 commit comments

Comments
 (0)