JForex-Utilities icon indicating copy to clipboard operation
JForex-Utilities copied to clipboard

NPE protection in com.quantisan.JFUtil.Pairer

Open qooyend opened this issue 14 years ago • 4 comments

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

qooyend avatar Jun 01 '11 10:06 qooyend

Hi Marcin,

Have you initialized JForexContext in onStart()?

Paul

On 1 June 2011 06:07, qooyend [email protected] 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

Quantisan avatar Jun 01 '11 13:06 Quantisan

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

Marcin

qooyend avatar Jun 01 '11 13:06 qooyend

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 [email protected] 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

Quantisan avatar Jun 01 '11 14:06 Quantisan

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.

qooyend avatar Jun 01 '11 15:06 qooyend