Hi Nicholas

I thought that this was a new problem that was detected after Steve Hruda 
fixed the other.

Thanks
John

On Tuesday, 7 April 2015 10:44:07 UTC-4, Nicolas Fortin (OrbisGIS) wrote:
>
> Hi,
>
> Sorry I didn't notice, shruda solve this issue and it has been merged in 
> h2:
>
> https://code.google.com/p/h2database/source/detail?r=6088
>
> Regards,
>
>  -- 
> Nicolas Fortin
> IRSTV FR CNRS 2488
> GIS        http://orbisgis.org
> Spatial DB http://h2gis.org 
> <http://www.google.com/url?q=http%3A%2F%2Fh2gis.org&sa=D&sntz=1&usg=AFQjCNH3xVHyQCTdh2pCB5uHdgu5F0u-yg>
> Noise      http://noisemap.orbisgis.org
>
>
>
> Le mardi 7 avril 2015 13:38:23 UTC+2, John McMahon a écrit :
>>
>> We are experiencing null pointer exceptions when we attempt to store a 
>> null geometry in H2 when we close the connection
>>
>> Attached is a small test.
>>
>> org.h2.jdbc.JdbcSQLException: General error: 
>> "java.lang.NullPointerException" [50000-186]
>> at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
>> at org.h2.message.DbException.get(DbException.java:168)
>> at org.h2.message.DbException.convert(DbException.java:295)
>> at org.h2.message.DbException.toSQLException(DbException.java:268)
>> at org.h2.message.TraceObject.logAndConvert(TraceObject.java:352)
>> at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:392)
>> at 
>> com.intergraph.test.NullGeometryTest.startTest(NullGeometryTest.java:46)
>> at com.intergraph.test.NullGeometryTest.main(NullGeometryTest.java:21)
>> Caused by: java.lang.NullPointerException
>> at org.h2.mvstore.rtree.SpatialDataType.write(SpatialDataType.java:89)
>> at org.h2.mvstore.rtree.SpatialDataType.write(SpatialDataType.java:80)
>> at org.h2.mvstore.Page.write(Page.java:735)
>> at org.h2.mvstore.Page.writeUnsavedRecursive(Page.java:818)
>> at org.h2.mvstore.MVStore.storeNowTry(MVStore.java:1057)
>> at org.h2.mvstore.MVStore.storeNow(MVStore.java:973)
>> at org.h2.mvstore.MVStore.commitAndSave(MVStore.java:962)
>> at org.h2.mvstore.MVStore.commit(MVStore.java:923)
>> at org.h2.mvstore.db.TransactionStore.close(TransactionStore.java:217)
>> at org.h2.mvstore.db.MVTableEngine$Store.close(MVTableEngine.java:346)
>> at org.h2.engine.Database.closeOpenFilesAndUnlock(Database.java:1359)
>> at org.h2.engine.Database.close(Database.java:1259)
>> at org.h2.engine.Database.removeSession(Database.java:1143)
>> at org.h2.engine.Session.close(Session.java:678)
>> at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:384)
>>
>> We found that a simple null check wasn't sufficient as it messes up the 
>> index.
>>
>> We instead added a line of code that created a dummy SpatialKey when the 
>> given key is null. This works for now but isn't a perfect solution.
>>
>>     @Override
>>     public void write(WriteBuffer buff, Object obj) {
>>         SpatialKey k = (SpatialKey) obj;
>>         int flags = 0;
>>         for (int i = 0; i < dimensions; i++) {
>>             if (k.min(i) == k.max(i)) {
>>                 flags |= 1 << i;
>>             }
>>         }
>>         buff.putVarInt(flags);
>>         for (int i = 0; i < dimensions; i++) {
>>             buff.putFloat(k.min(i));
>>             if ((flags & (1 << i)) == 0) {
>>                 buff.putFloat(k.max(i));
>>             }
>>         }
>>         buff.putVarLong(k.getId());
>>     }
>>
>>
>>     @Override
>>     public void write(WriteBuffer buff, Object obj) {
>>     if ( obj == null ){
>>     obj = new SpatialKey(0,0,0,0,0);
>>     }
>>         SpatialKey k = (SpatialKey) obj;
>>         int flags = 0;
>>         for (int i = 0; i < dimensions; i++) {
>>             if (k.min(i) == k.max(i)) {
>>                 flags |= 1 << i;
>>             }
>>         }
>>         buff.putVarInt(flags);
>>         for (int i = 0; i < dimensions; i++) {
>>             buff.putFloat(k.min(i));
>>             if ((flags & (1 << i)) == 0) {
>>                 buff.putFloat(k.max(i));
>>             }
>>         }
>>         buff.putVarLong(k.getId());
>>     }
>>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to