AbstractCachedAuthorityFactory is improperly caching dissimilar objects with the same key

Description

I am trying to export the CRS NAD27 / Michigan South with EPSG code 6202 from the latest EPSG database. While doing so I am getting the following ClassCastException

java.lang.ClassCastException: org.geotools.referencing.datum.DefaultGeodeticDatum cannot be cast to org.opengis.referencing.crs.CoordinateReferenceSystem
at org.geotools.referencing.factory.AbstractCachedAuthorityFactory.createCoordinateReferenceSystem(AbstractCachedAuthorityFactory.java:291)
at geotools.referencing.CacheBugTest.createSomeCrs(CacheBugTest.java:123)
at geotools.referencing.CacheBugTest.createSomeCrss(CacheBugTest.java:116)
at geotools.referencing.CacheBugTest.testCacheBug(CacheBugTest.java:62)
at geotools.referencing.CacheBugTest.main(CacheBugTest.java:195)

The root cause is that AbstractCachedAuthorityFactory is caching two dissimilar Objects with the same key. EPSG Datum 6202 is used in Australia whilst EPSG CRS 6202 is for South Michican. The code in the mentioned class just uses the key (6202) for both objects. That then causes the class cast exception.

Environment

None

Status

Assignee

Unassigned

Reporter

codehaus

Triage

None

Priority

High
Configure