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

DefaultBroadcaster.push contains recursive error #115

Closed
azell opened this issue Dec 8, 2011 · 3 comments
Closed

DefaultBroadcaster.push contains recursive error #115

azell opened this issue Dec 8, 2011 · 3 comments

Comments

@azell
Copy link

azell commented Dec 8, 2011

protected void push(Entry entry) {

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

    String prevMessage = entry.message.toString();
    if (!delayedBroadcast.isEmpty()) {
        Iterator<Entry> 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 other than String, the above code will call push() until it runs out of stack space.

@azell
Copy link
Author

azell commented Dec 9, 2011

It may be easiest to split push into two methods.

@jfarcand
Copy link
Member

jfarcand commented Dec 9, 2011

Wow great finding. Looking at it. Who wrote that code :-)

@jfarcand
Copy link
Member

Integrated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants