shashank created CAMEL-27087:
--------------------------------
Summary: camel-coap - every stop of an observe consumer
(observe=true) leaks the endpoint of its client: a bound UDP socket and its
threads
Key: CAMEL-27087
URL: https://issues.apache.org/jira/browse/CAMEL-27087
Project: Camel
Issue Type: Bug
Components: camel-coap
Reporter: shashank
Assignee: shashank
h3. What happens
The observe consumer ({{CoAPObserver}}, {{observe=true}}) creates its client
with {{CoAPEndpoint.createCoapClient}}, which gives the client its own
Californium {{CoapEndpoint}} (a bound UDP socket, or a DTLS / TCP connector,
with its receiver and sender threads). On stop the consumer cancels the
observation and calls {{CoapClient.shutdown()}}, which does not destroy that
endpoint. Each stop of the route (and each in-place stop of the consumer)
leaves one socket and its threads behind until the JVM ends.
CAMEL-26049 fixed the same leak in the producer; the consumer was left out on
purpose, because the endpoint carries the cancel of the observation
(CAMEL-25742), and the review of that PR agreed to a separate JIRA.
h3. How to reproduce
{{CoAPObserverStopDestroysEndpointTest}} (camel-coap): an observable resource
and an observe route; the observe route is stopped and started 5 times and then
stopped. Each stop removes the observation on the server, but the
{{UDP-Receiver}} threads of the 5 clients started during the test stay alive
(10 threads on main, expected 0).
h3. Fix
The stop waits for the answer to the cancel of the observation (the cancel
response, or an error), at most 5 seconds, and then destroys the endpoint of
the client. The cancel still reaches the server before the socket is closed.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)