Java shutdown hook is ignored (?) when using HCL Domino NotesThread

Viewed 138

I'm currently developing a Vaadin-based program in Java which extracts documents from Domino databases and writes them to a MongoDB collection. The program works perfectly but has one small flaw:

Currently i've found no way to stop the program other then send "KILL" to the process. My shutdown hook/signal handler is totally ignored. I've narrowed down the problem to a single line of code:

NotesThread.sinitThread();

When i remove this line, the hook works perfectly and my program is shutdown properly. When the line is inserted, then the hook is never called.

Here is some example code:

private boolean running = true;

...

@Override
public void run() {
    try {
        NotesGC.runWithAutoGC(() -> {
            NotesThread.sinitThread() // --> "Kills" all signal handling
            Session session = NotesFactory.createSession();
            
            while (running) {
                Thread.sleep(1000);
                System.out.println("Running ...");
            }

            session.recycle();

            return null;
        });
    } catch (Exception e) {
    } finally {
        NotesThread.stermThread();
    }
}

public void kill() {
        System.out.println("Killed!");
        this.running = false;
}

...

Signal.handle(new Signal("TERM"), sig -> runner.kill()); // Signal handler from main-method

I've asks friends and colleagues and nobody ever had the same problem.

1 Answers
Related