AtlasOfLivingAustralia / spatial-service

Spatial web services and layer administration console
https://spatial.ala.org.au/ws
2 stars 11 forks source link

Create a new layer fails with Numeric Overflow exception #247

Open StefanVanDyck opened 2 months ago

StefanVanDyck commented 2 months ago

Creating a new layer sometimes fails with the following error:

java.lang.Exception: exception just for purpose of providing stack trace
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement
Caused by: org.postgresql.util.PSQLException: ERROR: numeric field overflow

This is caused by incorrect parsing of the floating point numbers of the bounding box returned by geoserver. It only happens when setting the language to in our case nl_BE. This causes the grails i18n to change the number format locale to use a different decimal separator. A value of 5.911109415203301 therefor becomes 5.068749233044934E15, causing an overflow.

Looking at a way to properly parse the bounding box values without being affected by the users locale. Will create a PR to fix, current workaround is just to make sure we switch to English.

StefanVanDyck commented 2 months ago

Seem to have pinpointed where the number conversion fails.

The values in that map are strings, calling the setter on the Grails Entity converts them to number that are considering the locale, set in the front-end. Causing 5.911109415203301 to become 5.911109415203301E15.

StefanVanDyck commented 1 month ago

Created a proposal for a simple workaround: https://github.com/AtlasOfLivingAustralia/spatial-service/pull/251

It was getting very frustrating, making sure we always had the correct language selected when administering the layers.