Archived

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

Ice.Current.hashCode() can throw a NPE on null enum

Though it's fairly unlikely to ever get an Ice.Current without mode set, I did run into a NullPointerException while trying to unit test. There doesn't seem to be a good reason for the mode enumeration to not have a null check: (from 3.2.1)
    hashCode()
    {   
        int __h = 0;
        if(adapter != null)
        {   
            __h = 5 * __h + adapter.hashCode();
        }
        if(con != null)
        {
            __h = 5 * __h + con.hashCode();
        }
        __h = 5 * __h + id.hashCode();
        if(facet != null)
        {   
            __h = 5 * __h + facet.hashCode();
        }
        if(operation != null)
        {
            __h = 5 * __h + operation.hashCode();
        }
        __h = 5 * __h + mode.hashCode();
        if(ctx != null)
        {
            __h = 5 * __h + ctx.hashCode();
        }
        __h = 5 * __h + requestId;
        return __h;
    }   

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Thanks for the bug report. You're right there should be a null check here, we'll fix this!

    Cheers,
    Benoit.