allthingssecurity commented on PR #28536:
URL: https://github.com/apache/camel/pull/28536#issuecomment-6435470213

   @davsclaus thanks, good catch. Fixed in 4f7369126aad (a new commit on top, 
no squash).
   
   `process()` now takes `CoapClient coapClient = client;` right after 
`initClient()` and uses it everywhere after that: 
`CoAPHelper.getDefaultMethod`, the GET/DELETE/POST/PUT/PING calls and the "No 
response received" message (`URISupport.sanitizeUri(coapClient.getURI())`). 
Nothing in `process()` reads the field after that line any more.
   
   New test 
`CoAPProducerNoResponseTest.testStoppingTheProducerWithARequestInFlightFailsTheExchange`,
 with no sleeps. A producer sends a GET to a port where nothing listens. A 
message observer on the request signals when the datagram has been sent, and 
then the test stops the producer while it holds the request's monitor. 
Destroying the endpoint cancels the request, but the thread waiting in 
`Request.waitForResponse` can only go on after `doStop` has set `client` to 
null. The test expects the `CamelExchangeException` "No response received from 
CoAP server for GET". Without the local copy it fails 100 of 100 runs with 
`NullPointerException: ... because "this.client" is null`, and with it, it 
passes 100 of 100.
   
   camel-coap unit tests: 86 run, 0 failures. The formatter and import sort 
made no changes. I updated the description to match.
   
   One small window is left, as before this change: a stop between 
`initClient()` returning and the local copy being taken. Closing it would mean 
`initClient()` returning the client under its lock, which changes a protected 
method, so I left it; happy to do it if you prefer.
   
   Agreed on the follow-ups (the observe consumer's endpoint, `CoAPConsumer` 
without a `doStop`): they will be separate JIRAs.
   
   _Claude Code on behalf of allthingssecurity_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to