question

Upvote
Accepted
22 3 3 7

unregister() causes internal stack trace

I have written the simplest code example that returns a refresh message and it gets a internal stack trace on unregister(). What's wrong in these 40 lines?

OnMsgTest onMsgTest = new OnMsgTest(ommConsumer, symbol);
long handle = ommConsumer.registerClient(reqMsg.serviceName(source).name(symbol), onMsgTest);

and later

@Override
public void onAllMsg(Msg msg, OmmConsumerEvent consumerEvent) {
Long handle = consumerEvent.handle();
String s = "onAllMsg symbol=" + symbol + " handle=" + handle + " msg=" + msg.toString();
logger.info(s);
ommConsumer.unregister(handle);
}

and the stack trace [1;31mjava.lang.NullPointerException[m: [1;31mCannot invoke "com.refinitiv.ema.access.OmmConsumerClient.onRefreshMsg(com.refinitiv.ema.access.RefreshMsg, com.refinitiv.ema.access.OmmConsumerEvent)" because the return value of "com.refinitiv.ema.access.Item.client()" is null[m
[1mat[m com.refinitiv.ema.access.ItemCallbackClientConsumer.notifyOnRefreshMsg ([1mItemCallbackClient.java:2567[m)
[1mat[m com.refinitiv.ema.access.ItemCallbackClient.processRefreshMsg ([1mItemCallbackClient.java:1789[m)
[1mat[m com.refinitiv.ema.access.ItemCallbackClient.defaultMsgCallback ([1mItemCallbackClient.java:1626[m)
[1mat[m com.refinitiv.eta.valueadd.reactor.Reactor.sendDefaultMsgCallback ([1mReactor.java:2084[m)

#technologyexceptionommconsumerunregister
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

1 Answer

· Write an Answer
Upvote
Accepted
78.8k 250 52 74

@Patrick Sweeney

Thanks for reaching out to us.

The onAllMsg callback method is called before other callback methods, such as onRefreshMsg.

In the onAllMsg callback, the code unregistered an item handle from the consumer which means that it removed this subscription from the consumer. Therefore, when calling other callback methods, EMA may forget to check if the subscription has been removed which causes this NullPointerException.

1675820507833.png

If you are a Refinitiv Developer Connect (RDC) named user, you can submit this issue to the API support team via Contact Premium Support. Otherwise, you can report this issue on GitHub.

To avoid this issue, please don't call the unregister method in the onAllMsg callback method. You can call the unregister method in other callback methods instead.

Please feel free to reach out if you have any further questions.



1675820507833.png (40.2 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.