Skip to content

ISSUE-10: Race condition potential in ApplicationManager concurrent operations #423

@sfloess

Description

@sfloess

Severity: Medium

Type: Concurrency / Thread Safety

Description:
While ApplicationManager uses fine-grained locking per application, there are potential race conditions in operations that span multiple applications or access shared state.

Location:

  • platform-core/src/main/java/org/flossware/platform/core/ApplicationManager.java:970-986 (shutdown method)
  • Various places where lifecycle listeners are notified

Problem:

  1. The shutdown() method iterates over applications while other threads might be deploying/undeploying apps
  2. The ListenerExecutor uses unbounded task submission without backpressure
  3. Multiple lock acquisitions in sequence can deadlock if ordering is inconsistent across methods

Example race:
Thread 1: shutdown() iterates applications list
Thread 2: deploy() adds a new application
Result: Application might be deployed then immediately undeployed

Impact:
Medium - Can cause:

  • Applications left in inconsistent state during shutdown
  • Listener notifications lost
  • Potential deadlocks if care isn't taken with lock ordering

Recommendation:

  1. Use consistent lock ordering across all methods that acquire multiple locks
  2. Use snapshot-based iteration (already done on line 974) consistently everywhere
  3. Consider a RW-lock for the applications map during bulk operations
  4. Document lock ordering to prevent deadlocks in future maintenance

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