Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQLFeatureStore] Deleting features fails for certain feature type prefix configurations #848

Closed
MrSnyder opened this issue Sep 14, 2017 · 1 comment
Assignees
Labels
bug error issue and bug (fix) WFS deegree Web Feature Service
Milestone

Comments

@MrSnyder
Copy link
Contributor

MrSnyder commented Sep 14, 2017

We observed that a delete by feature id against an SQLFeatureStore fails in some cases. This issue seems to be related to certain feature prefix configuration and differs between Java versions, e.g. we have two feature types with the following feature id prefices:

  • APP_FEATURE_
  • APP_FEATURE_X

We found that deleting the feature with id "APP_FEATURE_X_1" works in a Java 7 setup (tested with OpenJDK 7, 1.7.0_151 on Ubuntu 14.04 AMD64), while it fails with an exception on Java 8 (same machine, Oracle JDK 8, 1.8.0_144).

A first analysis points to method analyze(String) in class org.deegree.feature.persistence.sql.id.IdAnalyzer:

...
        // TODO implement this more efficiently
        for ( String prefix : prefixToFt.keySet() ) {
            if ( featureOrGeomId.startsWith( prefix ) ) {
                ft = prefixToFt.get( prefix );
                break;
            }
        }
...

We believe this is caused by the different key order in the respective HashMap implementations:

https://stackoverflow.com/questions/38587711/hashmap-keyset-returns-keys-in-different-order-in-java-7-java-8

@MrSnyder MrSnyder added bug error issue and bug (fix) WFS deegree Web Feature Service labels Sep 14, 2017
@tfr42 tfr42 added this to the 3.4 milestone Sep 25, 2017
nitram509 added a commit to nitram509/deegree3 that referenced this issue Oct 2, 2017
…ertain feature type prefix configurations

Reason: when searching features by prefixes, one need to make sure,
the list to be searched is sorted. Else, a prefix named 'p' will wrongly
return a feature 'ppFeatureName'. The test shows a concrete example.
@MrSnyder
Copy link
Contributor Author

MrSnyder commented Oct 6, 2017

NOTE: I updated the description to make it more clear. And here are some hints for reproducing the issue:

Machine setup

I tested on Ubuntu 14.04 (AMD64) with OpenJDK 7 (1.7.0_151) and Oracle JDK 8 (1.8.0_144).

Setup PostGIS (Docker)

docker run -p 5432:5432 --name postgis -e POSTGRES_PASSWORD=postgres -d mdillon/postgis

After PostgreSQL is up, use the attached shell script (prepare_postgis_docker.sh.zip) to create two feature tables (feature and feature_x) and insert a row into each table.

Start deegree-webservices and activate reproducer workspace

I built deegree from the master branch (commit 3c99a88) and started deegree-webservices in Tomcat 7. Use the attached deegree workspace (deegree-workspace-idanalysis-ambiguity.zip) to get a basic SQLFeatureStore and a WFS configuration running.

Send transaction request to observe issue

Send the following transaction request to the WFS (e.g. via deegree's web interface):

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns="http://www.someserver.com/myns" xmlns:app="http://www.deegree.org/app" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" service="WFS" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <wfs:Delete handle="delete1" typeName="app:FeatureX">
    <fes:Filter>
      <fes:ResourceId rid="APP_FEATURE_X_1"/>
    </fes:Filter>
  </wfs:Delete>
</wfs:Transaction>

I get mixed results, depending on the JDK used to run deegree:

  • OpenJDK 7: Works as expected
  • Oracle JDK 8: OWS Exception, see below
<ows:ExceptionReport xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd" version="2.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ows:Exception exceptionCode="NoApplicableCode">
        <ows:ExceptionText>Error performing delete operation: For input string: "amp;X_1"amp;:</ows:ExceptionText>
    </ows:Exception>
</ows:ExceptionReport>

@MrSnyder MrSnyder self-assigned this Oct 6, 2017
nitram509 added a commit to nitram509/deegree3 that referenced this issue Nov 11, 2017
…ertain feature type prefix configurations

Reason: when searching features by prefixes, one need to make sure,
the list to be searched is sorted. Else, a prefix named 'p' will wrongly
return a feature 'ppFeatureName'. The test shows a concrete example.
MrSnyder pushed a commit to occamlabs/deegree3 that referenced this issue Nov 17, 2017
…ertain feature type prefix configurations

Reason: when searching features by prefixes, one need to make sure,
the list to be searched is sorted. Else, a prefix named 'p' will wrongly
return a feature 'ppFeatureName'. The test shows a concrete example.
copierrj added a commit that referenced this issue Feb 16, 2018
…nalysis-ambiguity

Fix #848 [SQLFeatureStore] Deleting features fails for certain feature type prefix configurations (3.3-backport)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug error issue and bug (fix) WFS deegree Web Feature Service
Projects
None yet
Development

No branches or pull requests

2 participants