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

Cached queries reuse the EvaluationContext [DATAKV-137] #116

spring-projects-issues opened this issue Jun 2, 2016 · 0 comments

Cached queries reuse the EvaluationContext [DATAKV-137] #116

spring-projects-issues opened this issue Jun 2, 2016 · 0 comments


Copy link

@spring-projects-issues spring-projects-issues commented Jun 2, 2016

Shijun Kong opened DATAKV-137 and commented

The following test will fail at the last assertion, with NPE.
I believe it is a bug in CachingKeyValuePartTreeQuery#cachedQuery.

After, the first findByName statement, the cachedQuery.criteria.context.variables contains User("Jack"), which later was deleted.

However, in the context, it is never been properly cleanup. So, the next findByName statement will yield NPE. Because "it" reference -> "Jack"

public class UserRepoTest {

    private UserRepo repo;

    public void testFindByName() throws Exception { User("Jack")); User("Mary"));

        User jack = repo.findByName("Jack");
        assertThat(jack.getName(), is("Jack"));


        Iterable<User> all = repo.findAll();
        assertThat(, false).count(), is(1L));
        assertThat(all.iterator().next().getName(), is("Mary"));

        User mary = repo.findByName("Mary");
        assertThat(mary.getName(), is("Mary"));


user is a simple pojo

public class User {

    private String uuid;

    private String name;

    public User(String name) { = name;

    public String getName() {
        return name;

    public void setName(String name) { = name;

    public String getUuid() {
        return uuid;

    public void setUuid(String uuid) {
        this.uuid = uuid;

public class AppConfig { }

public interface UserRepo extends CrudRepository<User, String> {

    User findByName(String name);

Affects: 1.1.1 (Hopper SR1)

Referenced from: pull request #20

Backported to: 1.1.2 (Hopper SR2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants