[Spread-users] SpreadMessage.addGroups() results in java.lang.ClassCastException

Matt Kowalczyk matt.kowalczyk at gmail.com
Fri Oct 2 03:01:19 EDT 2009


I was playing around with Spread today and I noticed that passing an 
array of SpreadGroup objects to SpreadMessage.addGroups() results in:

Exception in thread "main" java.lang.ClassCastException: 
[Lspread.SpreadGroup; cannot be cast to spread.SpreadGroup
    at spread.SpreadMessage.getGroups(SpreadMessage.java:481)
    at spread.SpreadConnection.multicast(SpreadConnection.java:1840)

The SpreadMessage.groups Vector expects objects of type SpreadGroup not 
SpreadGroup[]. The below patch should resolve the problem.

-Matt


diff -rup spread-src-4.1.0/java/spread/SpreadMessage.java 
spread-src-4.1.0.patched/java/spread/SpreadMessage.java
--- spread-src-4.1.0/java/spread/SpreadMessage.java     2009-06-18 
13:24:17.000000000 -0700
+++ spread-src-4.1.0.patched/java/spread/SpreadMessage.java     
2009-10-01 23:48:31.612759984 -0700
@@ -721,7 +721,7 @@ public class SpreadMessage
        {
                int len = groups.length;
                for(int i = 0 ; i < len ; i++)
-                       this.groups.addElement(groups);
+                       this.groups.addElement(groups[i]);
        }
 
        // Adds a group to the message's destination group list.





More information about the Spread-users mailing list