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

ResponseBodyEmitter skips same messages during initialization [SPR-13223] #17814

Closed
spring-issuemaster opened this issue Jul 11, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jul 11, 2015

Tomasz Nurkiewicz opened SPR-13223 and commented

When the same message is sent via ResponseBodyEmitter before initialization, subsequent messages are dropped because uses ResponseBodyEmitter#initHandlerCache map keys to store events.

Problematic code (using SseEmitter):

@RequestMapping("/sse")
public SseEmitter sse() throws IOException, InterruptedException {
	final SseEmitter emitter = new SseEmitter();
	emitter.send("A");
	emitter.send("B");
	emitter.send("C");
	emitter.complete();
	return emitter;
}

The response is:

data:A

BC

while it should be:

data:A

data:B

data:C

The reason is that both data: and \n\n are dropped as duplicates. Pull request with test case and fix comes shortly.


Affects: 4.2 RC2

Issue Links:

  • #17815 SseEmitter is not thread safe

Referenced from: commits bdb6348

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 11, 2015

Tomasz Nurkiewicz commented

PR: #837

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 13, 2015

Juergen Hoeller commented

Implemented together with #17815, using a common struct for a value with media type both in ResponseBodyEmitter and in SseEventBuilder, and using common synchronization for all affected operations - including the option to manually synchronize on the emitter, for aggregating multiple values just like SseEmitter does by default now.

Juergen

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.