Skip to content

[Enhancement] ThreadlessExecutor unable to handle all exceptions #6193

@AlbumenJ

Description

@AlbumenJ

ThreadlessExecutor unable to handle all exceptions throwed by task.

org.apache.dubbo.common.threadpool.ThreadlessExecutor

    public void waitAndDrain() throws InterruptedException {
        if (finished) {
            return;
        }

        Runnable runnable = queue.take();

        synchronized (lock) {
            waiting = false;
            runnable.run();
        }

        runnable = queue.poll();
        while (runnable != null) {
            try {
                runnable.run();
            } catch (Throwable t) {
                logger.info(t);

            }
            runnable = queue.poll();
        }
        finished = true;
    }

    @Override
    public void execute(Runnable runnable) {
        synchronized (lock) {
            if (!waiting) {
                sharedExecutor.execute(runnable);
            } else {
                queue.add(runnable);
            }
        }
    }

When execute tasks takes from queue or tasks directly executed by sharedExecutor, the exception throwed by task cannot be handled properly. Additional, tasks polled from queue are surround by exception handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions