# HG changeset patch # User Michael Schloh von Bennewitz # Date 1423600320 -3600 # Node ID e0e108e7705291e931e6b26981a79923f5584fe3 # Parent 45d57ecba7573f912dad756e4f6595011f3c9a53 Complete porting of ical4j to post getContextClassLoader() Android era, correcting critical flaws reported by users on the upstream bugtracker including https://github.com/gggard/AndroidCaldavSyncAdapater/issues/224/ diff -r 45d57ecba757 -r e0e108e77052 src/ical4j.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ical4j.properties Tue Feb 10 21:32:00 2015 +0100 @@ -0,0 +1,81 @@ +# +# Copyright (c) 2011, Ben Fortuna +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# o Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# o Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# o Neither the name of Ben Fortuna nor the names of any other contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# o Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# o Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# o Neither the name of Ben Fortuna nor the names of any other contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#net.fortuna.ical4j.parser=net.fortuna.ical4j.data.HCalendarParserFactory + +#net.fortuna.ical4j.timezone.registry=net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory + +#net.fortuna.ical4j.timezone.update.enabled={true|false} + +#net.fortuna.ical4j.timezone.date.floating={true|false} + +#net.fortuna.ical4j.factory.decoder=net.fortuna.ical4j.util.DefaultDecoderFactory + +#net.fortuna.ical4j.factory.encoder=net.fortuna.ical4j.util.DefaultEncoderFactory + +#net.fortuna.ical4j.recur.maxincrementcount=1000 + +#ical4j.unfolding.relaxed={true|false} + +ical4j.parsing.relaxed=true + +ical4j.validation.relaxed=true + +#ical4j.compatibility.outlook={true|false} + +#ical4j.compatibility.notes={true|false} diff -r 45d57ecba757 -r e0e108e77052 src/net/fortuna/ical4j/model/TimeZoneRegistryImpl.java --- a/src/net/fortuna/ical4j/model/TimeZoneRegistryImpl.java Tue Feb 10 19:58:00 2015 +0100 +++ b/src/net/fortuna/ical4j/model/TimeZoneRegistryImpl.java Tue Feb 10 21:32:00 2015 +0100 @@ -73,14 +73,14 @@ private static final Properties ALIASES = new Properties(); static { try { - ALIASES.load(ResourceLoader.getResourceAsStream("net/fortuna/ical4j/model/tz.alias")); + ALIASES.load(ResourceLoader.getResourceAsStream("tz.alias")); } catch (IOException ioe) { LogFactory.getLog(TimeZoneRegistryImpl.class).warn( "Error loading timezone aliases: " + ioe.getMessage()); } try { - ALIASES.load(ResourceLoader.getResourceAsStream("tz.alias")); + ALIASES.load(ResourceLoader.getResourceAsStream("/tz.alias")); } catch (Exception e) { LogFactory.getLog(TimeZoneRegistryImpl.class).debug( diff -r 45d57ecba757 -r e0e108e77052 src/net/fortuna/ical4j/util/ResourceLoader.java --- a/src/net/fortuna/ical4j/util/ResourceLoader.java Tue Feb 10 19:58:00 2015 +0100 +++ b/src/net/fortuna/ical4j/util/ResourceLoader.java Tue Feb 10 21:32:00 2015 +0100 @@ -54,11 +54,20 @@ public static URL getResource(String name) { URL resource = null; try { + // Hack to bootstrap a multithreaded class loader context + if (Thread.currentThread().getContextClassLoader() == null) + Thread.currentThread().setContextClassLoader(ResourceLoader.class.getClassLoader()); resource = Thread.currentThread().getContextClassLoader().getResource(name); + + if (resource == null) // Flawed build path for assets, try again + resource = Thread.currentThread().getContextClassLoader().getResource("/" + name); } catch (SecurityException e) { LOG.info("Unable to access context classloader, using default. " + e.getMessage()); } + catch (Exception e) { + LOG.info("General context classloader error, using default. " + e.getMessage()); + } if (resource == null) { resource = ResourceLoader.class.getResource("/" + name); } @@ -74,11 +83,19 @@ public static InputStream getResourceAsStream(String name) { InputStream stream = null; try { + // Hack to bootstrap a multithreaded class loader context + if (Thread.currentThread().getContextClassLoader() == null) + Thread.currentThread().setContextClassLoader(ResourceLoader.class.getClassLoader()); stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + if (stream == null) + stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/" + name); } catch (SecurityException e) { LOG.info("Unable to access context classloader, using default. " + e.getMessage()); } + catch (Exception e) { + LOG.info("General context classloader error, using default. " + e.getMessage()); + } if (stream == null) { stream = ResourceLoader.class.getResourceAsStream("/" + name); } diff -r 45d57ecba757 -r e0e108e77052 src/tz.alias --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/tz.alias Tue Feb 10 21:32:00 2015 +0100 @@ -0,0 +1,131 @@ +## Unsupported timezone identifiers.. +Etc/GMT+0=Etc/GMT +Etc/GMT-0=Etc/GMT +Etc/GMT0=Etc/GMT +GMT=Etc/GMT + +### Temporary hack to support above timezones.. +Etc/GMT=Europe/London +Etc/Greenwich=Etc/GMT +Etc/UCT=Europe/London +Etc/UTC=Europe/London +Etc/Universal=Etc/UTC + +Etc/Zulu=Etc/UTC + +## Non-Oslon aliases: +# +US/Pacific-New=America/Los_Angeles + +## Update Olson backward compatibility here: +# +Africa/Asmera = Africa/Asmara +Africa/Timbuktu = Africa/Bamako +America/Argentina/ComodRivadavia = America/Argentina/Catamarca +America/Atka = America/Adak +America/Buenos_Aires = America/Argentina/Buenos_Aires +America/Catamarca = America/Argentina/Catamarca +America/Coral_Harbour = America/Atikokan +America/Cordoba = America/Argentina/Cordoba +America/Ensenada = America/Tijuana +America/Fort_Wayne = America/Indiana/Indianapolis +America/Indianapolis = America/Indiana/Indianapolis +America/Jujuy = America/Argentina/Jujuy +America/Knox_IN = America/Indiana/Knox +America/Louisville = America/Kentucky/Louisville +America/Mendoza = America/Argentina/Mendoza +America/Porto_Acre = America/Rio_Branco +America/Rosario = America/Argentina/Cordoba +America/Virgin = America/St_Thomas +Asia/Ashkhabad = Asia/Ashgabat +Asia/Chungking = Asia/Chongqing +Asia/Dacca = Asia/Dhaka +Asia/Katmandu = Asia/Kathmandu +Asia/Calcutta = Asia/Kolkata +Asia/Macao = Asia/Macau +Asia/Tel_Aviv = Asia/Jerusalem +Asia/Saigon = Asia/Ho_Chi_Minh +Asia/Thimbu = Asia/Thimphu +Asia/Ujung_Pandang = Asia/Makassar +Asia/Ulan_Bator = Asia/Ulaanbaatar +Atlantic/Faeroe = Atlantic/Faroe +Atlantic/Jan_Mayen = Europe/Oslo +Australia/ACT = Australia/Sydney +Australia/Canberra = Australia/Sydney +Australia/LHI = Australia/Lord_Howe +Australia/NSW = Australia/Sydney +Australia/North = Australia/Darwin +Australia/Queensland = Australia/Brisbane +Australia/South = Australia/Adelaide +Australia/Tasmania = Australia/Hobart +Australia/Victoria = Australia/Melbourne +Australia/West = Australia/Perth +Australia/Yancowinna = Australia/Broken_Hill +Brazil/Acre = America/Rio_Branco +Brazil/DeNoronha = America/Noronha +Brazil/East = America/Sao_Paulo +Brazil/West = America/Manaus +Canada/Atlantic = America/Halifax +Canada/Central = America/Winnipeg +Canada/East-Saskatchewan = America/Regina +Canada/Eastern = America/Toronto +Canada/Mountain = America/Edmonton +Canada/Newfoundland = America/St_Johns +Canada/Pacific = America/Vancouver +Canada/Saskatchewan = America/Regina +Canada/Yukon = America/Whitehorse +Chile/Continental = America/Santiago +Chile/EasterIsland = Pacific/Easter +Cuba = America/Havana +Egypt = Africa/Cairo +Eire = Europe/Dublin +Europe/Belfast = Europe/London +Europe/Tiraspol = Europe/Chisinau +GB = Europe/London +GB-Eire = Europe/London +GMT+0 = Etc/GMT +GMT-0 = Etc/GMT +GMT0 = Etc/GMT +Greenwich = Etc/GMT +Hongkong = Asia/Hong_Kong +Iceland = Atlantic/Reykjavik +Iran = Asia/Tehran +Israel = Asia/Jerusalem +Jamaica = America/Jamaica +Japan = Asia/Tokyo +Kwajalein = Pacific/Kwajalein +Libya = Africa/Tripoli +Mexico/BajaNorte = America/Tijuana +Mexico/BajaSur = America/Mazatlan +Mexico/General = America/Mexico_City +NZ = Pacific/Auckland +NZ-CHAT = Pacific/Chatham +Navajo = America/Denver +PRC = Asia/Shanghai +Pacific/Samoa = Pacific/Pago_Pago +Pacific/Yap = Pacific/Chuuk +Pacific/Truk = Pacific/Chuuk +Pacific/Ponape = Pacific/Pohnpei +Poland = Europe/Warsaw +Portugal = Europe/Lisbon +ROC = Asia/Taipei +ROK = Asia/Seoul +Singapore = Asia/Singapore +Turkey = Europe/Istanbul +UCT = Etc/UCT +US/Alaska = America/Anchorage +US/Aleutian = America/Adak +US/Arizona = America/Phoenix +US/Central = America/Chicago +US/East-Indiana = America/Indiana/Indianapolis +US/Eastern = America/New_York +US/Hawaii = Pacific/Honolulu +US/Indiana-Starke = America/Indiana/Knox +US/Michigan = America/Detroit +US/Mountain = America/Denver +US/Pacific = America/Los_Angeles +US/Samoa = Pacific/Pago_Pago +UTC = Etc/UTC +Universal = Etc/UTC +W-SU = Europe/Moscow +Zulu = Etc/UTC