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

Comments

Projects
None yet
4 participants
@stffrdhrn
Copy link

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

This comment has been minimized.

Copy link
Contributor

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!

@jerrinot jerrinot self-assigned this Feb 1, 2019

@ahmetmircik

This comment has been minimized.

Copy link
Member

ahmetmircik commented Feb 1, 2019

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

@stffrdhrn

This comment has been minimized.

Copy link
Author

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.

@jerrinot

This comment has been minimized.

Copy link
Contributor

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();
    }
@stffrdhrn

This comment has been minimized.

Copy link
Author

stffrdhrn commented Feb 1, 2019

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

@jerrinot

This comment has been minimized.

Copy link
Contributor

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.

@mmedenjak

This comment has been minimized.

Copy link
Contributor

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.

@mmedenjak

This comment has been minimized.

Copy link
Contributor

mmedenjak commented Feb 21, 2019

Closed by mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.