Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

NullPointerException since comment is null
 Post subject: NullPointerException since comment is null Post rating: 0   New post Posted: Thu 23 Apr, 2009, 06:36 

User rating: 0
Joined: Tue 31 Mar, 2009, 07:19
Posts: 4
The following is a part of my code:

-------------------------------------------------------
for (IOrder order: engine.getOrders(instrument)) {
if (order.getComment().equals(COMMENT1)) {
-------------------------------------------------------

It caused NullPointerException at order.getComment().equals(COMMENT1)
after partial fill message.
Is this a bug of JForex?
If not, how can I avoid this error?
Thanks.


 
 Post subject: Re: NullPointerException Post rating: 0   New post Posted: Thu 23 Apr, 2009, 15:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This is not JForex bug since comment can be null in order. To avoid this, use construction like :

-------------------------------------------------------
for (IOrder order: engine.getOrders(instrument)) {
if (COMMENT1.equals(order.getComment())) {
-------------------------------------------------------

but only if COMMENT1 is constant or you sure it's not null, otherwise use additional check for null :
if (COMMENT1!=null && COMMENT1.equals(order.getComment()))


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com