Results 1 to 4 of 4

Thread: slice2sl 0.3.0 - code generation for dispatch__

  1. #1
    kwaclaw is offline Registered User
    Name: Karl Waclawek
    Organization: Personal
    Project: Whiteboard application
    Join Date
    Sep 2004
    Location
    Oshawa, Canada
    Posts
    159

    slice2sl 0.3.0 - code generation for dispatch__

    slice2sl generates code for the dispatch__ operation like this:
    Code:
    public override Ice.DispatchStatus dispatch__(IceInternal.Incoming inS__, Ice.Current current__)
    {
        int pos = _System.Array.BinarySearch(all__, current__.operation);
        . . .
    }
    The binary search shown above can fail to find the operation name, as no proper string comparison is performed, and then one gets an Ice.OperationNotExistException when one should not.

    Replacing the code above with
    Code:
    int pos = _System.Array.BinarySearch(all__, 0, all__.Length,
                current__.operation, IceUtil.StringUtil.OrdinalStringComparer);
    works for me.

    One could also replace the operations and types with their generic equivalents, i.e. BinarySearch<string> and IComparer<string>.

    Karl
    Karl Waclawek

  2. #2
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    Karl, can you detail what exactly isn't working?

  3. #3
    kwaclaw is offline Registered User
    Name: Karl Waclawek
    Organization: Personal
    Project: Whiteboard application
    Join Date
    Sep 2004
    Location
    Oshawa, Canada
    Posts
    159
    Quote Originally Posted by matthew View Post
    Karl, can you detail what exactly isn't working?

    Sure,

    My little demo app threw an Ice.OperationNotExistException when I was sure that both server and client (in this case it is a call-back) used the same slice definitions. So I stepped into the debugger, and noticed that BinarySearch returned a negative number, though I could see that the item it searched for (an operation name) was actually contained in the array.

    So, checking the docs for string.IComparable (used by BinarySearch) it states that this performs a culture sensitive comparison - I don't think this is desirable. Whether the binary search fails improperly or not will depend on the contents of the array and the locale used. It may oftent work properly, as it did for the other operations in my app. I then changed the generated code to perform an ordinal string comparison (as shown before), and the problem went away.

    Does that explain it?
    Karl Waclawek

  4. #4
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    Thanks for reporting this bug Karl. You can observe the bug with a slice interface such as the following:

    Code:
    interface Operations
    {
        void aaa();
        void AAB();
        void aac();
        void aad();
        void aae();
    };
    Try calling AAB and you'll get an ObjectNotExistException. Ice for .NET does not have this issue.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. slice2sl 0.3.0 - amd code generation
    By kwaclaw in forum Bug Reports
    Replies: 5
    Last Post: 09-23-2008, 01:00 PM
  2. Slice2Java code generation
    By JShah in forum Comments
    Replies: 1
    Last Post: 01-18-2008, 05:22 PM
  3. ICE 3.0.0 CS code generation issue
    By DeepDiver in forum Bug Reports
    Replies: 2
    Last Post: 11-18-2005, 01:48 PM
  4. Java 5.0 code generation for slice2java
    By vsonnathi in forum Comments
    Replies: 2
    Last Post: 11-17-2005, 01:58 PM
  5. C# code generation issue
    By DeepDiver in forum Bug Reports
    Replies: 3
    Last Post: 09-01-2005, 05:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •