Skip to content

QueuingTransactionReceiptProcessor should provide a mechanism of closing the scheduledExecutorService thread pool #2148

Open
@IvanovVenko

Description

@IvanovVenko

Bug description

When using QueuingTransactionReceiptProcessor in a Spring Boot, a crash (an exception thrown) during the singleton beans initialization phase leaves the Spring Boot application hanging.

Steps to reproduce

In a SpringBoot Application using web3j, in a bean constructor call:

  1. Create a QueuingTransactionReceiptProcessor:
    transactionReceiptProcessor = new QueuingTransactionReceiptProcessor(this.readWeb3j, callback, txManagerPollAttempts, txManagerPollSleepDuration);
  2. Throw an exception afterwards.

Expected behavior

The resources will be released and the Spring-boot application will exit.

Actual behavior

The resources are not released and the Spring boot application stays hanging, waiting all the hreads to quit. The reason is that the shutdown().
The cause is that the shutdown hook is set up only after the singleton beans are created and in this case the bean creation fails.

Environment

  • Web3j version: 4.12.3
  • Java : 21
  • Operating System: Ubuntu 22

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug in behaviour or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions