JSON totalFeatures can be wrong with spatial filters in WFS 1.1.0

Description

The filtering itself seems to be working since the number of matched features is correct.
But it's only for filters DISJOINT and BEYOND the matched features are returned.

I've only tested with the example polygon from the cql_tutorial.html against the topp:states sample data so I can only know that it doesn't work for DWITHIN, OVERLAPS, WITHIN and INTERSECTS since the others gives 0 matches.

DWITHIN:
http://localhost:8080/geoserver/topp/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=topp:states&outputFormat=application%2Fjson&CQL_FILTER=DWITHIN(the_geom%2C%20POLYGON((-90%2040%2C%20-90%2045%2C%20-60%2045%2C%20-60%2040%2C%20-90%2040)),%2010,%20meters)
Results in "totalFeatures": 38,"features": [],

OVERLAPS:
http://localhost:8080/geoserver/topp/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=topp:states&outputFormat=application%2Fjson&CQL_FILTER=OVERLAPS(the_geom%2C%20POLYGON((-90%2040%2C%20-90%2045%2C%20-60%2045%2C%20-60%2040%2C%20-90%2040)))
Results in "totalFeatures": 12,"features": [],

WITHIN:
http://localhost:8080/geoserver/topp/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=topp:states&outputFormat=application%2Fjson&CQL_FILTER=WITHIN(the_geom%2C%20POLYGON((-90%2040%2C%20-90%2045%2C%20-60%2045%2C%20-60%2040%2C%20-90%2040)))
Results in "totalFeatures": 3, "features": [],

INTERSECTS:
http://localhost:8080/geoserver/topp/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=topp:states&outputFormat=application%2Fjson&CQL_FILTER=INTERSECTS(the_geom%2C%20POLYGON((-90%2040%2C%20-90%2045%2C%20-60%2045%2C%20-60%2040%2C%20-90%2040)))
Results in "totalFeatures": 15,"features": [],

If I swap to WFS version 1.0.0 the features are returned.

Environment

Windows, Tomcat 7
GS 2.7.1 and nightly (12-Aug-2015 08:20)

Status

Assignee

Unassigned

Reporter

Olle Markljung

Triage

None

Fix versions

Affects versions

None

Components

Priority

Medium
Configure