Archived

This forum has been archived. Please start a new discussion on GitHub.

C#: callback (ice_response) problem

kwaclaw
kwaclaw Oshawa, Canada
I am getting a null pointer exception in the C# generated code when ice_response is called in an async dispatch situation.

The relevant Slice is:
struct Prop {
    int Index;
    Ice::ByteSeq Value;
  };
  
  sequence<Prop> PropSeq;

  interface Store {
     . . .
    ["ami", "amd"] idempotent
    PropSeq Get(Ice::ByteSeq key, Ice::IntSeq propIndexes) throws ServiceError;
     . . .
  };

The generated code for the call-back is as follows:
(I have marked the problem spot with a comment)
class _AMD_Store_Get : IceInternal.IncomingAsync, AMD_Store_Get
{
    public _AMD_Store_Get(IceInternal.Incoming inc) : base(inc)
    {
    }

    public void ice_response(Services.StorageServices.Prop[] ret__)
    {
        try
        {
            IceInternal.BasicStream os__ = this.os__();
            if(ret__ == null)
            {
                os__.writeSize(0);
            }
            else
            {
                os__.writeSize(ret__.Length);
                for(int ix__ = 0; ix__ < ret__.Length; ++ix__)
                {
                    ret__[ix__].write__(os__);  // issue here
                }
            }
        }
        catch(Ice.LocalException ex__)
        {
            ice_exception(ex__);
        }
        response__(true);
    }

    public void ice_exception(_System.Exception ex)
    {
        try
        {
            throw ex;
        }
        catch(Services.ServiceError ex__)
        {
            os__().writeUserException(ex__);
            response__(false);
        }
        catch(_System.Exception ex__)
        {
            exception__(ex__);
        }
    }
}

The problem occurs when the returned array contains nulls.

Karl

Comments

  • Thanks for the bug report. I'll post a patch ASAP.

    Cheers,

    Michi.
  • Hi Karl,

    I've posted a patch for the problem. Thanks for reporting this! You need to apply the patch to cpp/src/Slice/CsUtil.cpp, rebuild slice2cs, and recompile your Slice definitions.

    Cheers,

    Michi.
  • kwaclaw
    kwaclaw Oshawa, Canada
    michi wrote: »
    Hi Karl,

    I've posted a patch for the problem. Thanks for reporting this! You need to apply the patch to cpp/src/Slice/CsUtil.cpp, rebuild slice2cs, and recompile your Slice definitions.

    Cheers,

    Michi.

    Thanks, the fix seems to work.