Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to register zone as one already registered with that ID #31

Open
mjewild opened this issue Mar 8, 2024 · 0 comments
Open

Unable to register zone as one already registered with that ID #31

mjewild opened this issue Mar 8, 2024 · 0 comments

Comments

@mjewild
Copy link

mjewild commented Mar 8, 2024

Since updating to 2.1.8 I'm seeing the following when calling java.time.ZoneId.of:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at java.base/java.time.ZoneRegion.ofId(ZoneRegion.java:121)
	at java.base/java.time.ZoneId.of(ZoneId.java:411)
	at java.base/java.time.ZoneId.of(ZoneId.java:359)
	at Test.main(Test.java:9)
Caused by: java.time.zone.ZoneRulesException: Unable to register zone as one already registered with that ID: ical4j~e13c7b72-7f25-46ce-9ce9-e47946f19498, currently loading from provider: net.fortuna.ical4j.zoneinfo.outlook.OutlookZoneRulesProvider@4c1db628
	at java.base/java.time.zone.ZoneRulesProvider.registerProvider0(ZoneRulesProvider.java:324)
	at java.base/java.time.zone.ZoneRulesProvider.<clinit>(ZoneRulesProvider.java:191)
	... 4 more

This can be replicated with the following:

public static void main(final String[] args)
{
	ZoneId.of("Europe/London");
}

With org.mnode.ical4j:ical4j:4.0.0-rc3 declared on the classpath first, before org.mnode.ical4j:ical4j-zoneinfo-outlook:2.1.8
In maven the classpath order seems to come from the order the dependencies are declared.
The providers are then registered in the following order:

  1. net.fortuna.ical4j.model.DefaultZoneRulesProvider
  2. net.fortuna.ical4j.zoneinfo.outlook.OutlookZoneRulesProvider

The zone IDs for both come from net.fortuna.ical4j.model.DefaultZoneRulesProvider#provideZoneIds which is TimeZoneRegistry.ZONE_IDS.keySet()
i.e. it returns the same set of IDs twice

If the order of providers is reversed (OutlookZoneRulesProvider first) then the first time in provideZoneIds will return an empty Set as it hasn't been populated yet (done in the default constructor for DefaultZoneRulesProvider).
It therefore doesn't register the same set of IDs twice and doesn't fall over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant