Skip to content

ListenerConsumer doesn't handle JVM Error exception. #850

@ingvard

Description

@ingvard

Hello,
Need your advice. In my application, I make a simple health check for a listener container.

    protected void doHealthCheck(Health.Builder builder) {
        for (MessageListenerContainer container : listenerRegistry.getListenerContainers()) {
            if (!container.isRunning()) {
                builder.down();
                return;
            }
        }

        builder.up();
    }

But it doesn't work as expected, because if a listener thread throws an error exception like OutOfMemoryException (Type: Error), the exception isn't caught and the thread dies. The running flag would be true for a dead container.

I made a workaround, like -XX:+CrashOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError.
I understand that catching a throwable is a bad practice, but could you catch it and change the flag?:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions