JavaMoney / javamoney-examples

JavaMoney - Examples
Apache License 2.0
86 stars 39 forks source link

Requests rejected by IMF server on a regular basis #33

Closed keilw closed 4 years ago

keilw commented 6 years ago

Accessing the IMF looks very error-prone nowadays. Building the examples throws

WARNING: Failed to read/load resource (checking fallback): IMFHistoricRateProvider
java.lang.IllegalArgumentException: Failed to load new data: org.javamoney.moneta.convert.imf.IMFHistoricRateProvider{ context: ProviderContext (
{User-Agent=Chrome/51.0.2704.103, rateTypes=[HISTORIC], providerDescription=Historic International Monetary Fond, days=0, provider=IMF-HIST})}
    at org.javamoney.moneta.internal.loader.DefaultLoaderListener.trigger(DefaultLoaderListener.java:85)
    at org.javamoney.moneta.internal.loader.LoadDataLoaderService.execute(LoadDataLoaderService.java:41)
    at org.javamoney.moneta.internal.loader.DefaultLoaderServiceFacade.loadData(DefaultLoaderServiceFacade.java:43)
    at org.javamoney.moneta.internal.loader.DefaultLoaderService.loadData(DefaultLoaderService.java:264)
    at org.javamoney.moneta.convert.imf.IMFHistoricRateProvider.<init>(IMFHistoricRateProvider.java:66)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.javamoney.moneta.internal.PriorityAwareServiceProvider.loadServices(PriorityAwareServiceProvider.java:98)
    at org.javamoney.moneta.internal.PriorityAwareServiceProvider.getServices(PriorityAwareServiceProvider.java:65)
    at javax.money.spi.Bootstrap.getServices(Bootstrap.java:102)
    at org.javamoney.moneta.convert.internal.DefaultMonetaryConversionsSingletonSpi.reload(DefaultMonetaryConversionsSingletonSpi.java:64)
    at org.javamoney.moneta.convert.internal.DefaultMonetaryConversionsSingletonSpi.<init>(DefaultMonetaryConversionsSingletonSpi.java:56)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.javamoney.moneta.internal.PriorityAwareServiceProvider.loadServices(PriorityAwareServiceProvider.java:98)
    at org.javamoney.moneta.internal.PriorityAwareServiceProvider.getServices(PriorityAwareServiceProvider.java:65)
    at javax.money.spi.Bootstrap.getService(Bootstrap.java:113)
    at javax.money.convert.MonetaryConversions.getMonetaryConversionsSpi(MonetaryConversions.java:59)
    at javax.money.convert.MonetaryConversions.getExchangeRateProvider(MonetaryConversions.java:169)
    at org.javamoney.examples.test.MonetaryConversionTest.testGetExchangeRateProvider_Chained(MonetaryConversionTest.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.IllegalArgumentException: Failed to load IMF data provided.
    at org.javamoney.moneta.convert.imf.IMFAbstractRateProvider.newDataLoaded(IMFAbstractRateProvider.java:123)
    at org.javamoney.moneta.convert.imf.IMFHistoricRateProvider.newDataLoaded(IMFHistoricRateProvider.java:47)
    at org.javamoney.moneta.internal.loader.DefaultLoaderListener.trigger(DefaultLoaderListener.java:83)
    ... 54 more
Caused by: java.io.IOException: Request has been rejected by IMF server.
    at org.javamoney.moneta.convert.imf.IMFRateReadingHandler.read(IMFRateReadingHandler.java:66)
    at org.javamoney.moneta.convert.imf.IMFAbstractRateProvider.newDataLoaded(IMFAbstractRateProvider.java:114)
    ... 56 more

So it's not restricted to Russia, China or other countries, this happens in the EU as well. It won't break the overall build but we should find a solution or disable these tests or even reconsider certain exchange rate providers if IMF is no longer reliable.

keilw commented 6 years ago

Reopened https://github.com/JavaMoney/jsr354-ri/issues/191

Nevertheless here certain tests should probably not always be executed either or categorized via TestNG/JUnit along the lines of "Slow Running" etc. so they can be enabled only for certain build jobs.