Skip to content

GenericWorkflowClient can prevent exit of JVM #2450

@lverns

Description

@lverns

Expected Behavior

io.temporal.internal.client.external.GenericWorkflowClient should allow all resources to be reclaimed and not block natural termination of the JVM.

The Reproduction steps should finish with the java process exiting.

Actual Behavior

Once the asyncThrottlerExecutor in that class has started a thread, there is no mechanism to terminate it, and the JVM will not exit unless System.exit() is manually called.

The java call does not exit.

Steps to Reproduce the Problem

  1. Checkout the https://github.com/temporalio/money-transfer-project-java repo from the Getting Started tutorial .
  2. Add this commit on top: lverns/money-transfer-project-java@2492e11
  3. Generate a classpath: mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
  4. Compile mvn compile
  5. Run the worker:mvn exec:java -Dexec.mainClass="moneytransferapp.MoneyTransferWorker" -Dorg.slf4j.simpleLogger.defaultLogLevel=warn
  6. In another terminal run the app: java -cp $(cat cp.txt):target/classes moneytransferapp.TransferApp
  7. Observe that the app prints "Got Transfer complete", but the JVM remains running.
  8. If you inspect the process with jstack you will see a non-daemon thread called generic-wf-client-async-throttler that is preventing the JVM from exiting.

Specifications

  • Version: 1.24.1
  • Platform: Linux
  • Java Version: OpenJDK Runtime Environment (Red_Hat-21.0.6.0.7-1) (build 21.0.6+7)

Other notes

This seems to be a known issue based on a comment in the code, but opening this bug for visibility.

An easy work around is to call System.exit(0), but it seems possible that there are scenarios where a program might want to rely on the JVM's exit semantics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions