Closed msimons closed 1 year ago
A quick report on current status. I could not yet reproduce the issue with PROJ 8.2.1 (the version provided by my Fedora Linux distribution) because that version of PROJ seems to return a NULL
object for that coordinate operation. I previously thought that NULL
objects would be returned by the C/C++ API only when running out of memory, but there is apparently other possible reasons. The Java exception has been changed in #62 for reflecting that new assumption.
I'm lazily waiting for the Fedora distribution to upgrade to PROJ 9 before to test again. If it takes too long, I may try to compile locally later.
I finally could reproduce. No state were kept in Java code or in JNI bindings, we only have a pointer to PROJ PJ
object. We would need to test directly in C/C++ to confirm if this is a PROJ bug or if we missed something else. Or maybe it is part of PROJ contract to not use a PJ
object any more after an error. The fix applied in Java code is to unconditionally discard the native PJ
object after an error instead of recycling it for next operations.
Actually it seems that a better fix was already applied in a fork: https://github.com/interactive-instruments/PROJ-JNI/commit/c3b7e3b587ca19b307a6b6f47e441d8fc0f0a03e
Waiting for #63 to be fixed before to try the better fix.
Reverted previous fix and use proj_errno_reset(pj)
instead.
If a TransformException occurs when executing the
transform
method, each subsequent call results in the same error. It seems that certain state is not being cleaned up properly. In this situation we are now forced to create a new instance ofCoordinateOperation
. This is of course undesirable in the context of performance.The issue can be reproduced with the code below (PROJ9 & latest PROJ-JNI code).