Re: [jgroups-users] ArrayIndexOutOfBounds exception in STABLE.installView()

Questions/problems related to using JGroups <[email protected]> Tue, 6 Jun 2017 17:55:45 +0200
Newsgroups gmane.comp.java.javagroups.general
Message-ID <mailman.1607.1496764556.30453.javagroups-users@lists.sourceforge.net>
Hi Bruce,

a view without members, isn't that kind of a contradiction in itself? :-)

Joking aside, that's a scenario I've never considered... couldn't you 
just send a message CLEAR_VIEW instead?

There are many occurrences of code which calls View.getMembers() or 
View.getMembersRaw(), I'd have to review/change them all. Or at least 
the ones which check for coordinatorship.

Is the stack trace below the only place where an empty view causes problems?


On 05/06/17 23:51, Questions/problems related to using JGroups wrote:
> Hi,
>
> In Apache Geode I have a small protocol stack with no GMS where I manage
> and install my own membership view into the channel. During one
> transition I need to clear the view from the stack so I create a View
> with no members and send it in a view-change to the channel.
> Unfortunately STABLE isn't using View.getCoord() to get the current
> membership coordinator and is using getMembers().get(0) instead, causing
> an exception.
>
>         ViewId vid = new ViewId(new JGAddress(), 0);
>         List<Address> members = new ArrayList<>();
>         View jgv = new View(vid, members);
>         this.myChannel.down(new Event(Event.VIEW_CHANGE, jgv));
>
> java.lang.ArrayIndexOutOfBoundsException: 0
> at java.util.Arrays$ArrayList.get(Arrays.java:3841)
> at java.util.Collections$UnmodifiableList.get(Collections.java:1309)
> at org.jgroups.protocols.pbcast.STABLE.handleViewChange(STABLE.java:365)
> at org.jgroups.protocols.pbcast.STABLE.down(STABLE.java:328)
> at org.jgroups.protocols.FlowControl.down(FlowControl.java:347)
> at org.jgroups.protocols.FlowControl.down(FlowControl.java:347)
> at org.jgroups.protocols.FRAG2.down(FRAG2.java:136)
> at org.jgroups.stack.ProtocolStack.down(ProtocolStack.java:1039)
> at org.jgroups.JChannel.down(JChannel.java:790)
> at
> org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger.start(JGroupsMessenger.java:310)
>
>
> It seems like any use of View.getMembers().get(0) should be changed to
> View.getCoord() and the code should be prepared to deal with a null
> return value.
>
> Bruce Schuchardt
>
>
> ------------------------------------------------------------------------------
>
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> javagroups-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/javagroups-users

-- 
Bela Ban | http://www.jgroups.org


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot