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

Call method setBooleanAttribute of class Member cause java.lang.NullPointerException #6223

Closed
Xrew opened this issue Sep 15, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@Xrew
Copy link

commented Sep 15, 2015

Using hazelcast 3.5.2.

Hi,
problem is, that if i execute method setBooleanAttribute of class Member, than NullPointerException occured on STDOUT. I have debugged it and the problem is in class ClusterServiceImpl in method sendMemberAttributeEvent.
There is created event for service QuorumServiceImpl:

final MemberAttributeServiceEvent event = new MemberAttributeServiceEvent(getClusterProxy(), member, operationType, key, value);

This event inherit from MembershipEvent, and variable members is setted to null.

 public MemberAttributeEvent(Cluster cluster, Member member, MemberAttributeOperationType operationType,
                                String key, Object value) {
        super(cluster, member, MEMBER_ATTRIBUTE_CHANGED, null);
        this.member = member;
        this.operationType = operationType;
        this.key = key;
        this.value = value;
    }

Problem is, that this event is later in this method executed here:

 nodeEngine.getExecutionService().execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {
      public void run() {
           service.memberAttributeChanged(event);
      }
});

with service of instance QuorumServiceImpl and on the end by QuorumImpl, where exception is occurred in

private class MemberCountQuorumFunction implements QuorumFunction {
        @Override
        public boolean apply(Collection<Member> members) {
            return members.size() >= size;
        }
    }

because members variable is null.

Stacktrace:
Exception in thread "cached4" java.lang.NullPointerException at com.hazelcast.quorum.impl.QuorumImpl$MemberCountQuorumFunction.apply(QuorumImpl.java:179) at com.hazelcast.quorum.impl.QuorumImpl.update(QuorumImpl.java:63) at com.hazelcast.quorum.impl.QuorumServiceImpl.updateQuorums(QuorumServiceImpl.java:166) at com.hazelcast.quorum.impl.QuorumServiceImpl.memberAttributeChanged(QuorumServiceImpl.java:160) at com.hazelcast.cluster.impl.ClusterServiceImpl$8.run(ClusterServiceImpl.java:1295) at com.hazelcast.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:209) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76) at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)

@jerrinot jerrinot added this to the 3.6 milestone Sep 15, 2015

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Sep 15, 2015

@Xrew: Thank you for reporting the issue and your excellent analysis. It seems as a clear bug to me. Let's see what we can do about it.

@jerrinot jerrinot added VERIFIED and removed PENDING labels Sep 15, 2015

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Sep 15, 2015

The class hierarchy seems a bit odd. The MembershipEvent class says: Membership event fired when a new member is added to the cluster and/or when a member leaves the cluster.

However its subclass MemberAttributeServiceEvent says: This service event is fired to inform services about a change in a member's attributes collection.

@jerrinot jerrinot self-assigned this Sep 15, 2015

jerrinot added a commit to jerrinot/hazelcast that referenced this issue Sep 15, 2015

QuorumService ignores member attribute change events
Fixed hazelcast#6223
There is no member set in  MemberAttributeServiceEvent.

jerrinot added a commit to jerrinot/hazelcast that referenced this issue Sep 15, 2015

QuorumService ignores member attribute change events
Fixed hazelcast#6223
There is no member set in  MemberAttributeServiceEvent.
@Xrew

This comment has been minimized.

Copy link
Author

commented Sep 16, 2015

I would like to ask you, if there is some workaround of this issue. I need to use this...Thank you :-)

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2015

@Xrew:

The only (imperfect) workaround I can think of is to provide a custom quorum function. Something along these lines:

    private class StatefulMemberCountQuorumFunction implements QuorumFunction {
        private volatile boolean lastState;

        @Override
        public boolean apply(Collection<Member> members) {
            if (members == null) {
                return lastState;
            }
            boolean quorum = members.size() >= size;
            lastState = quorum;
            return quorum;
        }
    }
@Xrew

This comment has been minimized.

Copy link
Author

commented Sep 16, 2015

Thanks

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2015

@Xrew: No problem. Have a great day!

jerrinot added a commit to jerrinot/hazelcast that referenced this issue Sep 16, 2015

QuorumService ignores member attribute change events
Backport of hazelcast#6225, Fixes hazelcast#6223
There is no member set in MemberAttributeServiceEvent.
(cherry picked from commit eea2e7c)

Donnerbart added a commit to Donnerbart/hazelcast that referenced this issue Sep 17, 2015

QuorumService ignores member attribute change events
Fixed hazelcast#6223
There is no member set in  MemberAttributeServiceEvent.
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.