JDBCFeatureReader inspects the contents of the resultset even after going in
insertion mode
-------------------------------------------------------------------------------------------
Key: GEOT-2233
URL: http://jira.codehaus.org/browse/GEOT-2233
Project: GeoTools
Issue Type: Bug
Components: data jdbc-ng
Affects Versions: 2.5.2
Reporter: Andrea Aime
Assignee: Justin Deoliveira
Fix For: 2.5.3
ResultSetFeature.getAttributeInternal lazily loads attributes from the
resultset using a cache and a dirty map.
When going past the last feature using the writer this backfires since the
resultset is no more readable, so for each
null attribute there will be an attempt to read from it (as no setAttribute...
was called to mark it as dirty).
The mechanism must be blocked when going past the end of the resultset, if an
attribute wasn't written
by the user, it's simply null.
I've noticed this behaviour writing the PostgisDataStore test, in particular
after the failures in
testCreateSchemaWithConstraints and gestGetFeatureWriterAppend, that generate
the following stack trace:
{code}
java.lang.RuntimeException: org.geotools.data.DataSourceException: SQL
exception occurred while reading the geometry.
at
org.geotools.jdbc.JDBCFeatureReader$ResultSetFeature.getAttributeInternal(JDBCFeatureReader.java:866)
at
org.geotools.jdbc.JDBCFeatureReader$ResultSetFeature.getAttribute(JDBCFeatureReader.java:826)
at
org.geotools.jdbc.JDBCFeatureReader$ResultSetFeature.getAttribute(JDBCFeatureReader.java:818)
at
org.geotools.jdbc.JDBCFeatureReader$ResultSetFeature.getAttribute(JDBCFeatureReader.java:822)
at org.geotools.jdbc.JDBCDataStore.insertSQLPS(JDBCDataStore.java:2651)
at org.geotools.jdbc.JDBCDataStore.insert(JDBCDataStore.java:930)
at org.geotools.jdbc.JDBCDataStore.insert(JDBCDataStore.java:902)
at
org.geotools.jdbc.JDBCInsertFeatureWriter.write(JDBCInsertFeatureWriter.java:69)
at
org.geotools.jdbc.JDBCUpdateInsertFeatureWriter.write(JDBCUpdateInsertFeatureWriter.java:80)
at
org.geotools.data.InProcessLockingManager$1.write(InProcessLockingManager.java:335)
at
org.geotools.jdbc.JDBCDataStoreTest.testCreateSchemaWithConstraints(JDBCDataStoreTest.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at org.geotools.jdbc.JDBCTestSupport.run(JDBCTestSupport.java:100)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.geotools.data.DataSourceException: SQL exception occurred while
reading the geometry.
at org.geotools.data.postgis.WKBAttributeIO.read(WKBAttributeIO.java:91)
at
org.geotools.data.postgis.PostGISDialect.decodeGeometryValue(PostGISDialect.java:121)
at org.geotools.jdbc.SQLDialect.decodeGeometryValue(SQLDialect.java:581)
at
org.geotools.jdbc.JDBCFeatureReader$ResultSetFeature.getAttributeInternal(JDBCFeatureReader.java:859)
... 29 more
Caused by: org.postgresql.util.PSQLException: Il «ResultSet» non è
correttamente posizionato; forse è necessario invocare «next()».
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkResultSet(AbstractJdbc2ResultSet.java:2455)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBytes(AbstractJdbc2ResultSet.java:2034)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBytes(AbstractJdbc2ResultSet.java:2233)
at
org.apache.commons.dbcp.DelegatingResultSet.getBytes(DelegatingResultSet.java:253)
at
org.apache.commons.dbcp.DelegatingResultSet.getBytes(DelegatingResultSet.java:253)
at org.geotools.data.postgis.WKBAttributeIO.read(WKBAttributeIO.java:86)
... 32 more
{code}
Note the problem occurs because the geometry in the feature was not set
(legitimate, it's nullable in the
feature type), so the geometry field is not marked as dirty.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel