This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new e5d010c2e1 Add a safety for parsing a CRS code as an HTTP URL when
using the fallback factory. It seems necessary for the tests on the Jenkins
server. The reason why the code doesn't go through `MultiAuthoritiesFactory` on
the Jenkins server is unknown (we cannot reproduce this test failure locally).
e5d010c2e1 is described below
commit e5d010c2e165871526b7902352cae0800324485b
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue Apr 9 16:35:56 2024 +0200
Add a safety for parsing a CRS code as an HTTP URL when using the fallback
factory.
It seems necessary for the tests on the Jenkins server. The reason why the
code
doesn't go through `MultiAuthoritiesFactory` on the Jenkins server is
unknown
(we cannot reproduce this test failure locally).
---
.../org/apache/sis/referencing/EPSGFactoryFallback.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
index 38a495452a..d680035673 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
@@ -279,13 +279,16 @@ final class EPSGFactoryFallback extends
GeodeticAuthorityFactory
private Object predefined(String code, final int kind) throws
NoSuchAuthorityCodeException {
try {
/*
- * Parse the value after the last ':'. We do not bother to verify
if the part before ':' is legal
- * (e.g. "EPSG:4326", "EPSG::4326", "urn:ogc:def:crs:epsg::4326",
etc.) because this analysis has
- * already be done by MultiAuthoritiesFactory. We nevertheless
skip the prefix in case this factory
- * is used directly (not through MultiAuthoritiesFactory), which
should be rare. The main case is
- * when using the factory returned by
AuthorityFactories.fallback(…).
+ * Parse the value after the last ':' for an URN of the form
"urn:ogc:def:crs:epsg::4326",
+ * or after the last '#' for an URL of the form
"http://www.opengis.net/gml/srs/epsg.xml#4326".
+ * We do not bother to verify if the part before ':' or '#' is
legal because this analysis has
+ * already be done by `MultiAuthoritiesFactory`. The check for
separator should be unnecessary,
+ * but we nevertheless do it because this factory is sometime
invoked directly rather than through
+ * `MultiAuthoritiesFactory`. The direct invocation happens when
`CRS.forCode(String)` fallbacks
+ * on `AuthorityFactories.fallback(…)`.
*/
- code = CharSequences.trimWhitespaces(code,
code.lastIndexOf(Constants.DEFAULT_SEPARATOR) + 1, code.length()).toString();
+ final int s =
Math.max(code.lastIndexOf(Constants.DEFAULT_SEPARATOR), code.lastIndexOf('#'));
+ code = CharSequences.trimWhitespaces(code, s + 1,
code.length()).toString();
final short n = Short.parseShort(code);
if ((kind & (ELLIPSOID | DATUM | CRS)) != 0) {
for (final CommonCRS crs : CommonCRS.values()) {