[ 
https://issues.apache.org/jira/browse/AMQNET-637?focusedWorklogId=743418&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-743418
 ]

ASF GitHub Bot logged work on AMQNET-637:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Mar/22 20:36
            Start Date: 17/Mar/22 20:36
    Worklog Time Spent: 10m 
      Work Description: Havret commented on a change in pull request #18:
URL: 
https://github.com/apache/activemq-nms-openwire/pull/18#discussion_r829480693



##########
File path: src/Transport/FutureResponse.cs
##########
@@ -15,77 +15,23 @@
  * limitations under the License.
  */
 
-using System;
-using System.Threading;
+using System.Threading.Tasks;
 using Apache.NMS.ActiveMQ.Commands;
-using Apache.NMS.Util;
 
 namespace Apache.NMS.ActiveMQ.Transport
 {
        /// <summary>
        /// Handles asynchronous responses
        /// </summary>
-       public class FutureResponse
+       public class FutureResponse : TaskCompletionSource<Response>
        {
-               private TimeSpan maxWait = 
TimeSpan.FromMilliseconds(Timeout.Infinite);
-               public TimeSpan ResponseTimeout
+               public FutureResponse(): 
base(TaskCreationOptions.RunContinuationsAsynchronously)
                {
-                       get { return maxWait; }
-                       set { maxWait = value; }
                }
-
-               private readonly CountDownLatch latch = new CountDownLatch(1);
-               private Response response;
-
+               
                public Response Response
                {
-                       // Blocks the caller until a value has been set
-                       get
-                       {
-                               lock(latch)
-                               {
-                                       if(null != response)
-                                       {
-                                               return response;
-                                       }
-                               }
-
-                               try
-                               {
-                                       if(!latch.await(maxWait) && response == 
null)
-                                       {
-                                               throw new 
RequestTimedOutException(maxWait);
-                                       }
-                               }
-                               catch(RequestTimedOutException e)
-                               {
-                                       Tracer.Error("Caught Timeout Exception 
while waiting on monitor: " + e);
-                                       throw;
-                               }
-                               catch(Exception e)
-                               {
-                                       Tracer.Error("Caught Exception while 
waiting on monitor: " + e);
-                               }
-                               
-                               if(response == null && 
maxWait.TotalMilliseconds > 0)
-                               {
-                               }
-
-                               lock(latch)
-                               {
-                                       return response;
-                               }
-                       }
-
-                       set
-                       {
-                               lock(latch)
-                               {
-                                       response = value;
-                               }
-
-                               latch.countDown();
-                       }
+                       set => SetResult(value);

Review comment:
       This is not safe, it will throw an exception when you call `SetCanceled` 
or `SetException` first. I'd change it here and in other places to Try* 
equivalent. 




-- 
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 743418)
    Time Spent: 18h 20m  (was: 18h 10m)

> NMS 2.0
> -------
>
>                 Key: AMQNET-637
>                 URL: https://issues.apache.org/jira/browse/AMQNET-637
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: NMS
>    Affects Versions: 1.8.0
>            Reporter: Michael Andre Pearce
>            Priority: Major
>             Fix For: API-2.0.0
>
>          Time Spent: 18h 20m
>  Remaining Estimate: 0h
>
> NMS API is still at JMS 1.1 api level, this is to update the NMS api to the 
> latest JMS 2.0 apiĀ 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to