NullPointerException when printing FieldList content from update message to screen

Hi

When developing API according to Real-Time-SDK-2.0.0.L1.java, our client met NullPointerException when trying to print message content to screen in debug mode. Please find below screenshot:

imageHowever when print whole message which includes field list, it works. Please find below, the one in red circle are what client trying to extract:

image

Could you please help:

1. How to detect what was the cause of nullpointer?

2. If there any alternative way to locate and extract certain field from an message?

Thank you

Best Answer

  • Hi @Xiaorong.Xu

    Is the client accessing the Msg Payload outside the EMA thread e.g. they are trying to access the payload after returning from OnUpdateMsg handler?

    The EMA API owns the Msg and you cannot access it once you have returned from the event Handler callback e.g. onRefreshMsg(), onUpdateMsg() etc.

    If they want to access the Msg after returning from the above callbacks, then they should clone the msg before using in a different thread e.g.

    public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event)
    {
    UpdateMsg clonedUpdMsg = EmaFactory.createUpdateMsg(updateMsg);
    // store / pass clonedUpdMsg for use in other thread..
    //......
    return;
    }

Answers