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

Wrong logic in UUIDBroadcasterCache may cause messages lost #1176

Closed
jfarcand opened this issue Jul 3, 2013 · 0 comments
Closed

Wrong logic in UUIDBroadcasterCache may cause messages lost #1176

jfarcand opened this issue Jul 3, 2013 · 0 comments
Labels

Comments

@jfarcand
Copy link
Member

jfarcand commented Jul 3, 2013

                activeClients.put(clientId, now);
                if (isAtmosphereResourceValid(r)) {//todo better to have cacheLost flag
                    /**
                     * This line is called for each AtmosphereResource (note that
                     * broadcaster.getAtmosphereResources() may not return the current AtmosphereResource because
                     * the resource may be destroyed by DefaultBroadcaster.executeAsyncWrite or JerseyBroadcasterUtil
                     * concurrently, that is why we need to check duplicates),
                     *
                     * Cache the message only once for the clients
                     * which are not currently connected to the server
                     */
                    Broadcaster broadcaster = getBroadCaster(r.getAtmosphereConfig(), broadcasterId);
                    List<AtmosphereResource> resources = new ArrayList<AtmosphereResource>(broadcaster.getAtmosphereResources());
                    Set<String> disconnectedClients = getDisconnectedClients(resources);
                    for (String disconnectedId : disconnectedClients) {
                        addMessageIfNotExists(disconnectedId, cacheMessage);
                    }
                } else {
                    /**
                     * Cache lost message, caching only for specific client.
                     * Preventing duplicate inserts because this method can be called
                     * concurrently from DefaultBroadcaster.executeAsyncWrite or JerseyBroadcasterUtil
                     * when calling cacheLostMessage
                     */
                    addMessageIfNotExists(clientId, cacheMessage);
                }

The code above is wrong, e.g messages MUST always be cached => so the disconnect logic must be removed

jfarcand added a commit that referenced this issue Jul 3, 2013
@jfarcand jfarcand closed this as completed Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant