sahvx655-wq created FELIX-6839:
----------------------------------
Summary: Resolve lifecycle race condition in EventDispatcher
start/stop sequence
Key: FELIX-6839
URL: https://issues.apache.org/jira/browse/FELIX-6839
Project: Felix
Issue Type: Bug
Components: Framework
Reporter: sahvx655-wq
A race condition can occur in {{EventDispatcher}} during concurrent framework
start/stop operations within the same JVM.
When a framework instance is stopped and quickly restarted (or when multiple
framework instances are started and stopped concurrently in the same JVM),
{{EventDispatcher.startDispatching()}} may be called while the dispatch thread
from the previous lifecycle is still in the process of shutting down
({{{}m_stopping == true{}}}).
If {{startDispatching()}} is called at this moment:
# The method checks whether the dispatch thread is alive or null.
# Since the stopping thread is still alive, no new dispatch thread is started.
# Shortly afterward, the stopping thread exits completely.
# The {{EventDispatcher}} is left without an active dispatch thread even
though the framework expects events to be dispatched.
This can result in inconsistent dispatcher lifecycle behavior during concurrent
framework lifecycle transitions.
Modify {{EventDispatcher.startDispatching()}} to wait on {{m_threadLock}} while
{{m_stopping}} is {{{}true{}}}.
This ensures that any ongoing shutdown sequence completes before a new dispatch
thread is initialized, preventing overlapping lifecycle transitions and
ensuring that a valid dispatch thread is available after framework startup.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)