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

NullPointerException using setAsync() with 3.11.1 #14445

Closed
stffrdhrn opened this issue Feb 1, 2019 · 8 comments
Closed

NullPointerException using setAsync() with 3.11.1 #14445

stffrdhrn opened this issue Feb 1, 2019 · 8 comments

Comments

@stffrdhrn
Copy link

@stffrdhrn stffrdhrn commented Feb 1, 2019

Similar issues have been reported a few times. In the case here I have been able to trace this down to the code in SetOperation. It is not setting dataOldValue because my IMap has no query cache. However, I do have event listeners registered.

Current code

    @Override
    public void run() {
        Object oldValue = recordStore.set(dataKey, dataValue, ttl, maxIdle);
        newRecord = oldValue == null;

        if (recordStore.hasQueryCache()) {   //<< Need to also check if any eventService registrations exist
            dataOldValue = mapServiceContext.toData(oldValue);
        }
    }

Workaround

As a temporary workaround I have changed the SetOperation to the following and it works fine. Its not optimal because it desterilizes even if there are no listeners.

    @Override
    public void run() {
        dataOldValue = mapServiceContext.toData(recordStore.set(dataKey, dataValue, ttl, maxIdle));
    }

The Stack Trace

16:36:30.952 [hz._hzInstance_1_snet.partition-operation.thread-8] ERROR [] c.h.m.i.o.SetOperation-[127.0.0.1]:5701 [xxx] [3.11.1] null
java.lang.NullPointerException: null
    at com.hazelcast.query.impl.CachedQueryEntry.getTargetObject(CachedQueryEntry.java:105) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.query.impl.QueryableEntry.extractAttributeValue(QueryableEntry.java:81) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.query.impl.QueryableEntry.getAttributeValue(QueryableEntry.java:48) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.query.impl.predicates.AbstractPredicate.readAttributeValue(AbstractPredicate.java:133) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.query.impl.predicates.AbstractPredicate.apply(AbstractPredicate.java:58) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.query.PredicateBuilder.apply(PredicateBuilder.java:51) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.query.QueryEventFilter.eval(QueryEventFilter.java:54) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.event.AbstractFilteringStrategy.evaluateQueryEventFilter(AbstractFilteringStrategy.java:77) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.event.QueryCacheNaturalFilteringStrategy.processQueryEventFilterWithAlternativeEventType(QueryCacheNaturalFilteringStrategy.java:162) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.event.QueryCacheNaturalFilteringStrategy.doFilter(QueryCacheNaturalFilteringStrategy.java:124) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.event.MapEventPublisherImpl.publishEvent(MapEventPublisherImpl.java:233) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.event.MapEventPublisherImpl.publishEvent(MapEventPublisherImpl.java:187) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.operation.BasePutOperation.afterRun(BasePutOperation.java:53) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.map.impl.operation.SetOperation.afterRun(SetOperation.java:51) ~[hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.afterRun(OperationRunnerImpl.java:299) [hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.call(OperationRunnerImpl.java:213) [hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:197) [hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:147) [hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:125) [hazelcast-3.11.1.jar:3.11.1]
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:110) [hazelcast-3.11.1.jar:3.11.1]
@mmedenjak
Copy link
Contributor

@mmedenjak mmedenjak commented Feb 1, 2019

@stffrdhrn thank you for the report.
@ahmetmircik can you take a quick look if we can fix this for 3.11.2? Thanks!

Loading

@jerrinot jerrinot self-assigned this Feb 1, 2019
@ahmetmircik
Copy link
Member

@ahmetmircik ahmetmircik commented Feb 1, 2019

@stffrdhrn can you please confirm that you set hazelcast.map.entry.filtering.natural.event.types to true?

Loading

@stffrdhrn
Copy link
Author

@stffrdhrn stffrdhrn commented Feb 1, 2019

@ahmetmircik
Sorry, I can't check that right now. I am out of the office and will be back in one week. I'll be able to confirm then, but that setting seems familiar.

Loading

@jerrinot
Copy link
Contributor

@jerrinot jerrinot commented Feb 1, 2019

@stffrdhrn: once again thanks for awesome hints. with your stacktrace and @ahmetmircik comment it was trivial to write a reproducer:

    @Test
    public void testWithSetMethod() throws InterruptedException {
        Config config = new Config();
        config.setProperty("hazelcast.map.entry.filtering.natural.event.types", "true");

        IMap<String, Person> map = createHazelcastInstance(config).getMap("map");
        final CountDownLatch latch = new CountDownLatch(1);
        map.addEntryListener(new MapListenerAdapter<String, Person>() {
            @Override
            public void entryUpdated(EntryEvent<String, Person> event) {
                latch.countDown();
            }
        }, greaterEqual("age", 21), true);

        map.set("foo", new Person(42, "Arthur Dent"));
        map.set("foo", new Person(42, "Ford Prefect"));

        latch.await();
    }

Loading

@stffrdhrn
Copy link
Author

@stffrdhrn stffrdhrn commented Feb 1, 2019

@jerrinot that test looks right to me. Great job figuring it out so fast.

Loading

@jerrinot
Copy link
Contributor

@jerrinot jerrinot commented Feb 1, 2019

@stffrdhrn: we are about to start pre-release tests for 3.11.2. Let's see if we can squeeze this in.

Loading

@mmedenjak
Copy link
Contributor

@mmedenjak mmedenjak commented Feb 4, 2019

Fix has been merged for 3.11.2, moving issue to 3.12 to fix the issue in a less intrusive way.

Loading

@mmedenjak
Copy link
Contributor

@mmedenjak mmedenjak commented Feb 21, 2019

Closed by mistake.

Loading

@mmedenjak mmedenjak removed this from the 3.12 milestone Feb 25, 2019
@mmedenjak mmedenjak added this to the 3.13 milestone Feb 25, 2019
@mmedenjak mmedenjak removed this from the 3.13 milestone Feb 28, 2019
@mmedenjak mmedenjak added this to the 3.12 milestone Feb 28, 2019
@mmedenjak mmedenjak removed their assignment Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants