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

MapLoader NPE on loadAll(Collection) when value is null and MapLoader implements PostProcessingMapStore or has an Interceptor #11081

Closed
gokhanoner opened this issue Aug 12, 2017 · 3 comments

Comments

@gokhanoner
Copy link
Contributor

@gokhanoner gokhanoner commented Aug 12, 2017

in 3.8.3

    public static final class TestMapLoader extends MapStoreAdapter<String, String> implements PostProcessingMapStore{

        @Override
        public Iterable<String> loadAllKeys() {
            return Arrays.asList("1", "2", "null");
        }

        @Override
        public Map<String, String> loadAll(Collection<String> keys) {
            Map<String, String> val = new HashMap<>();
            val.put("1", "1");
            val.put("2", null);
            val.put("null", "");
            return val;
        }

    }

causes this:

Aug 12, 2017 5:38:44 AM com.hazelcast.map.impl.recordstore.DefaultRecordStore
WARNING: [192.168.0.27]:5701 [gokhan] [3.8.3] Found an attempt to load a null value from map-store, ignoring it.
Aug 12, 2017 5:38:44 AM com.hazelcast.map.impl.operation.PutFromLoadAllOperation
SEVERE: [192.168.0.27]:5701 [gokhan] [3.8.3] null
java.lang.NullPointerException
	at com.hazelcast.map.impl.operation.PutFromLoadAllOperation.run(PutFromLoadAllOperation.java:75)
	at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:186)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:120)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:100)

Aug 12, 2017 5:38:45 AM com.hazelcast.map.impl.recordstore.DefaultRecordStore
SEVERE: [192.168.0.27]:5701 [gokhan] [3.8.3] Exception while loading map test6
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:69)
	at com.hazelcast.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:228)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
	at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:64)
	at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:80)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrowIfException(InvocationFuture.java:88)
	at com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:155)
	at com.hazelcast.map.impl.recordstore.BasicRecordStoreLoader.loadValuesInternal(BasicRecordStoreLoader.java:127)
	at com.hazelcast.map.impl.recordstore.BasicRecordStoreLoader.access$100(BasicRecordStoreLoader.java:55)
	at com.hazelcast.map.impl.recordstore.BasicRecordStoreLoader$GivenKeysLoaderTask.call(BasicRecordStoreLoader.java:107)
	at com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:67)
	... 6 more
Caused by: java.lang.NullPointerException
	at com.hazelcast.map.impl.operation.PutFromLoadAllOperation.run(PutFromLoadAllOperation.java:75)
	at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:186)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:120)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:100)
	at ------ submitted from ------.(Unknown Source)
	at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolve(InvocationFuture.java:114)
	at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrowIfException(InvocationFuture.java:75)
	... 11 more

instead of implementing PostProcessingMapStore, if map has an Interceptor, same exception occurs.

@gokhanoner gokhanoner changed the title MapLoader NPE on loadAll(Collection) when value is null and MapLoader implements PostProcessingMapStore or has and Interceptor MapLoader NPE on loadAll(Collection) when value is null and MapLoader implements PostProcessingMapStore or has an Interceptor Aug 12, 2017
@mdogan
Copy link
Contributor

@mdogan mdogan commented Aug 14, 2017

@gokhanoner: IMap doesn't support null key or value.

See http://docs.hazelcast.org/docs/3.8.4/javadoc/com/hazelcast/core/IMap.html

This class does not allow null to be used as a key or value.

@gokhanoner
Copy link
Contributor Author

@gokhanoner gokhanoner commented Aug 14, 2017

@mdogan The problem is Hazelcast do some null checks, see:

WARNING: [192.168.0.27]:5701 [gokhan] [3.8.3] Found an attempt to load a null value from map-store, ignoring it.

But then, if Map has an Interceptor or a MapLoader implements PostProcessingMapStore, then it passes this control & throws NPE:

            Record record = recordStore.getRecord(key);
            if (isPostProcessing(recordStore)) {
                value = record.getValue();
            }

That's the problem. If key/value is null, after that point we shouldn't continue to process data.

@tombujok tombujok added this to the 3.9 milestone Aug 14, 2017
@tombujok tombujok added the Team: Core label Aug 14, 2017
@tombujok tombujok self-assigned this Aug 14, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 14, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 14, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 14, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 15, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 15, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 15, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 15, 2017
@tombujok
Copy link
Contributor

@tombujok tombujok commented Aug 17, 2017

Fixed by improving the NullPointerException message via #11097. The documentation has been also supplemented. MapLoaders are not allowed not return null/key values.

@tombujok tombujok closed this Aug 17, 2017
tombujok pushed a commit to tombujok/hazelcast that referenced this issue Aug 28, 2017
tombujok added a commit that referenced this issue Aug 29, 2017
* Fixes #11078 #11079 #11081 by improving validation

* Checked existence of key in-memory before proceed

* Test case for map-loader hitting eviction in PutFromLoadAll
tombujok added a commit to tombujok/hazelcast that referenced this issue Sep 1, 2017
…1253)

* Fixes hazelcast#11078 hazelcast#11079 hazelcast#11081 by improving validation

* Checked existence of key in-memory before proceed

* Test case for map-loader hitting eviction in PutFromLoadAll
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.

None yet
4 participants
You can’t perform that action at this time.