- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 101
Open
Labels
Milestone
Description
How to reproduce
Create class extending ECBCurrentRateProvider with broken resource url
public class BrokenECBCurrentRateProvider extends ECBCurrentRateProvider {
    private static final String DATA_ID = BrokenECBCurrentRateProvider.class.getSimpleName();
    public BrokenECBCurrentRateProvider() {
        super();
    }
    @Override
    public String getDataId() {
        return DATA_ID;
    }
    @Override
    protected LoadDataInformation getDefaultLoadData() {
        Map<String, String> props = new HashMap<>();
        props.put("period", "03:00");
        return (new LoadDataInformationBuilder())
                .withResourceId(this.getDataId())
                .withUpdatePolicy(LoaderService.UpdatePolicy.SCHEDULED)
                .withProperties(props)
                // The same BackupResource as in the ECBCurrentRateProvider class
                .withBackupResource(URI.create("org/javamoney/moneta/convert/ecb/defaults/eurofxref-daily.xml")) 
                // Broken url intentionally
                .withResourceLocations(URI.create("https://broken-url.xml"))
                .withStartRemote(true)
                .build();
    }
}
then create object of this class and you will get such exceptions
Expected
org.javamoney.moneta.spi.loader.okhttp.LoadableHttpResource load
WARNING: Failed to load resource input for BrokenECBCurrentRateProvider from https://broken-url.xml
java.net.UnknownHostException: broken-url.xml: nodename nor servname provided, or not known
Not expected
Apr 03, 2025 8:46:57 AM org.javamoney.moneta.spi.loader.okhttp.LoadableHttpResource load
WARNING: Failed to load resource input for BrokenECBCurrentRateProvider from org/javamoney/moneta/convert/ecb/defaults/eurofxref-daily.xml
java.lang.IllegalArgumentException: URI is not absolute
	at java.base/java.net.URL.of(URL.java:862)
	at java.base/java.net.URI.toURL(URI.java:1172)
	at org.javamoney.moneta.spi.loader.okhttp.LoadableHttpResource.load(LoadableHttpResource.java:316)
	at org.javamoney.moneta.spi.loader.okhttp.LoadableHttpResource.loadFallback(LoadableHttpResource.java:248)
	at org.javamoney.moneta.spi.loader.okhttp.LoadableHttpResource.load(LoadableHttpResource.java:146)
	at org.javamoney.moneta.spi.loader.okhttp.OkHttpScheduler$1.run(OkHttpScheduler.java:132)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
	at java.base/java.util.TimerThread.run(Timer.java:516)
this will result in the total deadlock of currency service if you try to use getExchangeRate method because in the ECBAbstractRateProvider the loadLock will never get released.
I would expect that fallback resource configured in the ECBCurrentRateProvider would load , but now this part of class configuration is broken.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In Review