Quantisan / JForex-Utilities

a suite of common utilities for JForex
http://www.quantisan.com/jfutil-an-open-source-jforex-utilities-library/
29 stars 17 forks source link

NPE protection in com.quantisan.JFUtil.Pairer #1

Open qooyend opened 13 years ago

qooyend commented 13 years ago

Hello,

I just began playing with JForex, have found your utils and am experimenting with it. And I stumbled upon a simple issue.

In Pairer class line 92 you have

subscribeSet.add(INSTANCE.pairs.get(secondCurr));

which inputs a null into the set and strategy fails to start. I do not know how the subscription behaves, so if you need some additional info about my setup, go ahead.

Keep up the good work:) Regards, Marcin

Quantisan commented 13 years ago

Hi Marcin,

Have you initialized JForexContext in onStart()?

Paul

On 1 June 2011 06:07, qooyend reply@reply.github.com wrote:

Hello,

I just began playing with JForex, have found your utils and am experimenting with it. And I stumbled upon a simple issue.

In Pairer class line 92 you have

subscribeSet.add(INSTANCE.pairs.get(secondCurr));

which inputs a null into the set and strategy fails to start. I do not know how the subscription behaves, so if you need some additional info about my setup, go ahead.

Keep up the good work:) Regards, Marcin

Reply to this email directly or view it on GitHub: https://github.com/Quantisan/JForex-Utilities/issues/1

qooyend commented 13 years ago

Yes, I was in fact running an exact copy from your jfutilDemo in test package.

Marcin

Quantisan commented 13 years ago

Could you post the exception stack please? And what's the currency you were trying to add? I haven't added all the currencies into the map.

On 1 June 2011 09:41, qooyend reply@reply.github.com wrote:

Yes, I was in fact running an exact copy from your jfutilDemo in test package.

Marcin

Reply to this email directly or view it on GitHub: https://github.com/Quantisan/JForex-Utilities/issues/1#comment_1274355

qooyend commented 13 years ago

Here it is: java.lang.NullPointerException at com.dukascopy.dds2.greed.gui.component.tree.i.a(Unknown Source) at com.dukascopy.dds2.greed.agent.q.subscribeToInstruments(Unknown Source) at com.dukascopy.api.impl.connect.JForexTaskManager.setSubscribedInstruments(Unknown Source) at com.dukascopy.api.impl.connect.an.setSubscribedInstruments(Unknown Source) at com.dukascopy.api.impl.connect.t.setSubscribedInstruments(Unknown Source) at com.quantisan.JFUtil.Pairer.subscribeTransitionalInstruments(Pairer.java:105) at pl.alepo.jforex.strategy.ProxyStrategy.onStart(ProxyStrategy.java:50) at com.dukascopy.api.impl.execution.s.call(Unknown Source) at com.dukascopy.api.impl.connect.an.a(Unknown Source) at com.dukascopy.api.impl.connect.v.call(Unknown Source) at com.dukascopy.api.impl.connect.v.call(Unknown Source) at com.dukascopy.api.impl.execution.i.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at com.dukascopy.api.impl.execution.e$a.f(Unknown Source) at com.dukascopy.api.impl.execution.e$a.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

I have your source, so I insereted Instrument inst = INSTANCE.pairs.get(secondCurr); if (inst != null ) subscribeSet.add( inst ); // transitional pair

and it does the trick.

I don't understand your second question. I wasn't adding anything. The error manifests itself with many pairs in workspace as well as only 3: AUD/USD, EUR/USD and USD/JPY.