Browse files

- Fixed NPE (https://issues.jboss.org/browse/JGRP-1443)

  • Loading branch information...
1 parent 9d1d017 commit e9239c55ad084f15cd86f3d2751d039d456f7aba @belaban committed Apr 2, 2012
View
10 src/org/jgroups/protocols/pbcast/CoordGmsImpl.java
@@ -9,6 +9,7 @@
import org.jgroups.util.Digest;
import org.jgroups.util.MergeId;
import org.jgroups.util.MutableDigest;
+import org.jgroups.util.Tuple;
import java.util.*;
@@ -152,8 +153,11 @@ public void handleMembershipChange(Collection<Request> requests) {
if(gms.members.contains(mbr)) { // already joined: return current digest and membership
if(log.isWarnEnabled())
log.warn(mbr + " already present; returning existing view " + gms.view);
- JoinRsp join_rsp=new JoinRsp(new View(gms.getViewId(), gms.members.getMembers()), gms.getDigest());
- gms.sendJoinResponse(join_rsp, mbr);
+ Tuple<View,Digest> tuple=gms.getViewAndDigest();
+ if(tuple != null) {
+ JoinRsp join_rsp=new JoinRsp(tuple.getVal1(), tuple.getVal2());
+ gms.sendJoinResponse(join_rsp, mbr);
+ }
it.remove();
}
}
@@ -220,7 +224,7 @@ public void handleMembershipChange(Collection<Request> requests) {
}
sendLeaveResponses(leaving_mbrs); // no-op if no leaving members
- gms.castViewChange(new_view,join_rsp != null? join_rsp.getDigest() : null,join_rsp,new_mbrs);
+ gms.castViewChange(new_view, join_rsp != null? join_rsp.getDigest() : null, join_rsp, new_mbrs);
}
finally {
if(hasJoiningMembers)
View
7 src/org/jgroups/protocols/pbcast/GMS.java
@@ -152,6 +152,13 @@ public GMS() {
public ViewId getViewId() {return view != null? view.getViewId() : null;}
+ /** Returns the current view and digest */
+ public Tuple<View,Digest> getViewAndDigest() {
+ Digest digest=getDigest();
+ View tmp_view=view != null? view.copy() : null;
+ return tmp_view != null? new Tuple<View,Digest>(tmp_view, digest) : null;
+ }
+
@ManagedAttribute
public String getView() {return view != null? view.getViewId().toString() : "null";}
@ManagedAttribute
View
4 src/org/jgroups/protocols/pbcast/JoinRsp.java
@@ -87,6 +87,8 @@ public void writeTo(DataOutput out) throws Exception {
if(digest != null && view != null) { // if digest is present, view *has* to be present !
for(Address mbr: view) {
long[] seqnos=digest.get(mbr);
+ if(seqnos == null)
+ seqnos=new long[]{-1, -1};
Util.writeLongSequence(seqnos[0], seqnos[1], out);
}
}
@@ -123,6 +125,8 @@ public void readFrom(DataInput in) throws Exception {
for(int i=0; i < size; i++) {
Address mbr=members.get(i);
long[] seqnos=Util.readLongSequence(in);
+ if(seqnos[0] == -1 && seqnos[1] == -1)
+ continue;
tmp.add(mbr, seqnos[0], seqnos[1], false);
}
digest=tmp;

0 comments on commit e9239c5

Please sign in to comment.