More investigation...
Having a look in org.geotools.imageio.unidata.UnidataVariableAdapter; the cause
of the problem revolves around the definition and usage of globalDomainExtent
(line 278).
This is used to store DateRanges and NumberRanges. Each range has a comparator
defined in org.geotools.coverage.io.util package; but these comparators don't
have enough commonality to create a super comparator. Is it enough to create a
comparator just to resolve this issue. Is the exact order important? The use of
TreeSet seems to imply that an order is important.
I could fix this with some direction. What are your thoughts?
Brett
________________________________
From: Brett Walker [brett.wal...@geometryit.com]
Sent: Thursday, 18 July 2013 12:00 AM
To: Andrea Aime
Cc: geotools-devel@lists.sourceforge.net
Subject: [Geotools-devel] Build breaks on JDK7 in module NetCDF Gridc Coverage
module
Hi Andrea,
I have found a build break when done using JDK7. The build breaks in Coverage
Experiment/NetCDF Grid Coverage Module.
This is caused by a subtle change in the definition of TreeMap#put(K key, V
value) in Java 7 when compared in Java 6. Look at the source code and follow
the code in Java 7 and a Comparable cast is made on keys. This is not done in
Java 6. This cast is the point at which the exception is thrown.
Caused by: java.lang.ClassCastException: org.geotools.util.NumberRange cannot
be cast to java.lang.Comparable
at java.util.TreeMap.compare(TreeMap.java:1188)
at java.util.TreeMap.put(TreeMap.java:531)
at java.util.TreeSet.add(TreeSet.java:255)
at
org.geotools.imageio.unidata.UnidataVariableAdapter$UnidataAdditionalDomain.<init>(UnidataVariableAdapter.java:314)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.addAdditionalDomain(UnidataVariableAdapter.java:708)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.initSpatialElements(UnidataVariableAdapter.java:436)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.init(UnidataVariableAdapter.java:388)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.<init>(UnidataVariableAdapter.java:851)
at
org.geotools.imageio.unidata.UnidataImageReader.getCoverageDescriptor(UnidataImageReader.java:767)
... 32 more
If I knew where the TreeSet in created and changed it to use a custom
comparator, then I believe that this would fix the breaking build. I haven't
tracked down the offending file (looking into this) but you may have a much
better idea.
Brett
(Full Stacktrace)
Running org.geotools.coverage.io.netcdf.NetCDFReaderTest
Jul 17, 2013 11:40:43 AM org.geotools.coverage.io.netcdf.NetCDFFormat getReader
org.geotools.data.DataSourceException: Unable to connect
at
org.geotools.coverage.io.netcdf.NetCDFReader.<init>(NetCDFReader.java:153)
at
org.geotools.coverage.io.netcdf.NetCDFFormat.getReader(NetCDFFormat.java:95)
at
org.geotools.coverage.io.netcdf.NetCDFReaderTest.NetCDFTestAscatL1(NetCDFReaderTest.java:494)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
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: org.geotools.data.DataSourceException: java.io.IOException:
java.lang.RuntimeException: java.lang.ClassCastException:
org.geotools.util.NumberRange cannot be cast to java.lang.Comparable
at
org.geotools.coverage.io.netcdf.NetCDFAccess.<init>(NetCDFAccess.java:132)
at
org.geotools.coverage.io.netcdf.NetCDFDriver.connect(NetCDFDriver.java:87)
at
org.geotools.coverage.io.impl.DefaultFileDriver.process(DefaultFileDriver.java:216)
at
org.geotools.coverage.io.netcdf.NetCDFReader.<init>(NetCDFReader.java:151)
... 24 more
Caused by: java.lang.RuntimeException: java.io.IOException:
java.lang.RuntimeException: java.lang.ClassCastException:
org.geotools.util.NumberRange cannot be cast to java.lang.Comparable
at
org.geotools.imageio.unidata.UnidataImageReader.setInput(UnidataImageReader.java:255)
at javax.imageio.ImageReader.setInput(ImageReader.java:380)
at
org.geotools.coverage.io.netcdf.NetCDFAccess.<init>(NetCDFAccess.java:118)
... 27 more
Caused by: java.io.IOException: java.lang.RuntimeException:
java.lang.ClassCastException: org.geotools.util.NumberRange cannot be cast to
java.lang.Comparable
at
org.geotools.imageio.unidata.UnidataImageReader.initIndex(UnidataImageReader.java:384)
at
org.geotools.imageio.unidata.UnidataImageReader.init(UnidataImageReader.java:643)
at
org.geotools.imageio.unidata.UnidataImageReader.setInput(UnidataImageReader.java:253)
... 29 more
Caused by: java.lang.RuntimeException: java.lang.ClassCastException:
org.geotools.util.NumberRange cannot be cast to java.lang.Comparable
at
org.geotools.imageio.unidata.UnidataImageReader.getCoverageDescriptor(UnidataImageReader.java:769)
at
org.geotools.imageio.unidata.UnidataImageReader.initIndex(UnidataImageReader.java:311)
... 31 more
Caused by: java.lang.ClassCastException: org.geotools.util.NumberRange cannot
be cast to java.lang.Comparable
at java.util.TreeMap.compare(TreeMap.java:1188)
at java.util.TreeMap.put(TreeMap.java:531)
at java.util.TreeSet.add(TreeSet.java:255)
at
org.geotools.imageio.unidata.UnidataVariableAdapter$UnidataAdditionalDomain.<init>(UnidataVariableAdapter.java:314)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.addAdditionalDomain(UnidataVariableAdapter.java:708)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.initSpatialElements(UnidataVariableAdapter.java:436)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.init(UnidataVariableAdapter.java:388)
at
org.geotools.imageio.unidata.UnidataVariableAdapter.<init>(UnidataVariableAdapter.java:851)
at
org.geotools.imageio.unidata.UnidataImageReader.getCoverageDescriptor(UnidataImageReader.java:767)
... 32 more
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel