Qpid
  1. Qpid
  2. QPID-3193

.NET Binding for Messaging classes need a test to check that binding is still in effect

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.11
    • Fix Version/s: 0.15
    • Component/s: None
    • Labels:
      None

      Description

      The .NET Binding for Messaging could be made more user-friendly with the addition of a property that indicates whether or not the underlying binding is still available. A C# coder may innocently write:

      (1) Message mA = new Message("a");
      (2) Message mB = mA;
      ...
      (N) mB.Dispose();

      After disposing of message mB then message mA is clobbered. 'Message' is a 'ref class' type and messages mA and mB refer to the same object on managed heap. When message mB is disposed then the bound C++ Messaging object is deleted [1]. Any reference to the bound message part of mA will result in an illegal memory reference (to 0) and a process exit. The .NET runtime can't catch this fault.

      The obvious answer is not to do that. If the second line of code was 'Message mB = new Message(mA)' then mA and mB would have been completely separate and disposing of either would have no effect on the other.

      Another answer is to have the binding check for a null binding reference on each and every access and then to throw if the underlying binding is gone. This is not very appealing from a performance standpoint.

      As a compromise I would like to add a property isBound to each class. Users then have a fighting chance to check that the binding is still in effect and that function calls on the object shouldn't blow up. This property would be useful in Assert statements or in debugging.

      [1] If anyone knows how to have my binding library intercept example code line (2) and create reference counts, please let me know.

        Activity

        Chuck Rolke created issue -
        Chuck Rolke made changes -
        Field Original Value New Value
        Attachment QPID-3694_lock-and-throw-preview.patch [ 12507722 ]
        Chuck Rolke made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 0.15 [ 12319043 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Chuck Rolke
            Reporter:
            Chuck Rolke
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development