escapeChar="" causes StringIndexOutOfBoundsException

Description

Get records in this form (with escapeChar="") :

<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:ows="http://www.opengis.net/ows" service="CSW" version="2.0.2" resultType="results" startPosition="1" maxRecords="6"><csw:Query typeNames="csw:Record"><csw:ElementSetName>full</csw:ElementSetName><csw:Constraint version="1.1.0"><ogc:Filter><ogcropertyIsLike wildCard="%" singleChar="_" escapeChar=""><ogcropertyName>csw:AnyText</ogcropertyName><ogc:Literal>test</ogc:Literal></ogcropertyIsLike></ogc:Filter></csw:Constraint></csw:Query></csw:GetRecords>

Causes an Exception :
ava.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.geotools.filter.LikeToRegexConverter.<init>(LikeToRegexConverter.java:47)
at org.geotools.filter.LikeFilterImpl.getMatcher(LikeFilterImpl.java:199)
at org.geotools.filter.LikeFilterImpl.evaluate(LikeFilterImpl.java:407)
at org.geotools.filter.AndImpl.evaluate(AndImpl.java:44)
at org.geoserver.catalog.impl.DefaultCatalogFacade$1.apply(DefaultCatalogFacade.java:1193)
at org.geoserver.catalog.impl.DefaultCatalogFacade$1.apply(DefaultCatalogFacade.java:1189)
at com.google.common.collect.Iterators$7.computeNext(Iterators.java:647)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
at org.geoserver.catalog.util.CloseableIteratorAdapter.hasNext(CloseableIteratorAdapter.java:47)
at org.geoserver.csw.store.internal.CatalogStoreFeatureIterator.nextLayer(CatalogStoreFeatureIterator.java:119)
at org.geoserver.csw.store.internal.CatalogStoreFeatureIterator.<init>(CatalogStoreFeatureIterator.java:98)
at org.geoserver.csw.store.internal.CatalogStoreFeatureCollection.openIterator(CatalogStoreFeatureCollection.java:68)
at org.geoserver.csw.feature.AbstractFeatureCollection.features(AbstractFeatureCollection.java:50)
at org.geoserver.csw.feature.AbstractFeatureCollection.size(AbstractFeatureCollection.java:346)
at org.geoserver.csw.store.AbstractCatalogStore.getRecordsCount(AbstractCatalogStore.java:145)
at org.geoserver.csw.GetRecords.run(GetRecords.java:105)

The request is valid but it fails.

Environment

None

Activity

Show:
Andrea Aime
February 15, 2017, 11:48 AM

Mass closing all resolved issues not modified in the last 4 weeks

Andrea Aime
May 21, 2016, 8:28 AM

Hi Ian, that's what I thought as well, but:

  • The XML schema does not say anything against empty strings

  • GeoNetwork does not complain against the same query, meaning clients would expect this to work regardless. GeoNetwork does not equate for the standard for sure, but it's likely what CSW clients are tested against.
    So, for this case at least, I believe it's better to be tolerant rather than throw an error.

Ian Turton
May 20, 2016, 5:20 PM

Infact I would think that an empty escape char is invalid but the error
message could be better.
On 20 May 2016 17:08, "Lorenzo Natali (JIRA)" <jira@osgeo-org.atlassian.net>

Fixed

Assignee

Andrea Aime

Reporter

Lorenzo Natali

Fix versions

Affects versions