Skip to content

geoNear() queries fail when the accompanying query returns no results [DATAMONGO-1361] #2277

@spring-projects-issues

Description

@spring-projects-issues

Bjorn Harvold opened DATAMONGO-1361 and commented

I found that if I a run a geoNear query with an accompanying search query that doesn't return any results, I encounter an NPE here.

java.lang.NullPointerException
	at org.springframework.data.mongodb.core.MongoTemplate.geoNear(MongoTemplate.java:667)
	at org.springframework.data.mongodb.core.MongoTemplate.geoNear(MongoTemplate.java:618)

Example document:

{
	"id": "1",
	"available": false,
        "location": {
            "type": "Point",
            "coordinates": [
              40.758934,
              -73.992514
            ]
        }
}

if the query looks like this:

NearQuery q = NearQuery.near(point).maxDistance(new Distance(maxDistance, Metrics.KILOMETERS));
q.query(where("available").is(true));

You get the NPE. Let me know if you need more information from me


Affects: 1.8.2 (Gosling SR2)

Referenced from: commits 160de0a, 2949908, 8ddbc3c

Backported to: 1.8.4 (Gosling SR4), 1.7.3 (Fowler SR3)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core supporttype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions