Atmosphere/atmosphere — Issue #115: DefaultBroadcaster.push contains recursive error
Author: azell
Created: 2011-12-08 23:53:41+00:00
State: open

protected void push(Entry entry) {

if (destroyed.get()) {
return;
}

String prevMessage = entry.message.toString();
if (!delayedBroadcast.isEmpty()) {
Iterator

i = delayedBroadcast.iterator();
StringBuilder b = new StringBuilder();
while (i.hasNext()) {
Entry e = i.next();
e.future.cancel(true);
try {
// Append so we do a single flush
if (e.message instanceof String
&& entry.message instanceof String) {
b.append(e.message);
} else {
push(e); // Problem here!
}
} finally {
i.remove();
}
}

if (b.length() > 0) {
entry.message = b.append(entry.message).toString();
}
}

If we pass a delayed broadcast with a message type of than String, the above code will call push() until it runs out of stack space.