Uploaded image for project: 'OpenICF'
  1. OpenICF
  2. OPENICF-1544

Fix double-checked locking in WebSocketConnectionGroup

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.20.0
    • None
    • 1
    • 2021.02 - Agents

    Description

      This block of code in WebSocketConnectionGroup doesn't perform thread locking properly:

              if (null == operationContext) {
                  synchronized (this) {
                      if (null == operationContext) {
                          operationContext = new RemoteOperationContext(connectionPrincipal, this);
                      }
                  }
              }
      

      This can be fixed by using the volatile keyword here:

      private volatile RemoteOperationContext operationContext = null;    
      

      See: https://wiki.sei.cmu.edu/confluence/display/java/LCK10-J.+Use+a+correct+form+of+the+double-checked+locking+idiom

      When this occurs, I see the following in the RCS logs:

      Feb 18, 2021 12:24:33 PM WARN  o.f.o.f.remote.OpenICFServerAdapter: Client received request 360,287,970,189,659,121 before handshake via socket:1,802,106,811 	Method: handleRequestMessage 
      

      Attachments

        Issue Links

          Activity

            People

              travis.haagen Travis Haagen [X] (Inactive)
              travis.haagen Travis Haagen [X] (Inactive)
              Son Nguyen Son Nguyen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: