Skip to content

bug: RestartManager.performRestart() uses Thread.sleep(1000) between stop and start - fragile timing #424

@sfloess

Description

@sfloess

Description

In RestartManager.java, the performRestart() method uses a hardcoded Thread.sleep(1000) between stopping and starting an application. This approach is fragile because:

  1. The stop operation may not complete within 1 second (especially for apps with long shutdown hooks)
  2. 1 second may be unnecessarily long for apps that stop quickly
  3. Thread.sleep() wastes a thread that could be used for other work
  4. If the thread is interrupted during sleep, the restart may proceed with a partially stopped application

Location

platform-core/src/main/java/org/flossware/platform/core/RestartManager.java

  • performRestart() method, Thread.sleep(1000) between stop and start calls

Impact

  • Unreliable restarts: if stop takes longer than 1 second, start may fail or conflict
  • Wasted time: simple apps wait the full second unnecessarily
  • Thread waste: sleeping thread cannot serve other requests

Suggested Fix

  1. Wait for the stop operation to complete (using a completion callback or polling the application state) before starting
  2. Use a CompletableFuture chain instead of blocking sleep
  3. If a delay is truly needed, make it configurable rather than hardcoded

Labels

bug

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