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

fix: Fix regression when sync id check is disabled #17238

Merged
merged 4 commits into from Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -76,7 +76,10 @@ public BroadcastAction filter(String broadcasterId, AtmosphereResource r,
String uuid = r.uuid();
int lastSeenOnClient = session.getAttribute(SEEN_SERVER_SYNC_ID,
Integer.class);
if (pushMessage.alreadySeen(lastSeenOnClient)) {
if (lastSeenOnClient == -1) {
return new BroadcastAction(BroadcastAction.ACTION.CONTINUE,
message);
} else if (pushMessage.alreadySeen(lastSeenOnClient)) {
getLogger().trace(
"Discarding message {} for resource {} as client already seen {}. {}",
pushMessage.serverSyncId, uuid, lastSeenOnClient,
Expand Down
Expand Up @@ -81,6 +81,19 @@ public void filter_notLongPollingTransport_continueWithCurrentMessage() {
verifyMessageIsNotCached();
}

@Test
public void filter_syncIdCheckDisabled_continueWithCurrentMessage() {
setTransport(AtmosphereResource.TRANSPORT.LONG_POLLING);
setSeenServerSyncIdHeader(-1);
BroadcastAction action = filter.filter("broadcasterId", resource,
originalMessage, message);
Assert.assertEquals(ACTION.CONTINUE, action.action());
Assert.assertSame(
"Message should not be altered by filter if server sync id header is missing",
TatuLund marked this conversation as resolved.
Show resolved Hide resolved
message, action.message());
verifyMessageIsNotCached();
}

@Test
public void filter_missingLastSeenServerSyncId_continueWithCurrentMessage() {
setTransport(AtmosphereResource.TRANSPORT.LONG_POLLING);
Expand Down Expand Up @@ -224,4 +237,4 @@ private void simulatePushConnection() {
private void verifyMessageIsNotCached() {
Mockito.verifyNoInteractions(cache);
}
}
}