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

WebTestClient cannot block when receive infinity stream of SSE #24131

Closed
Slava96 opened this issue Dec 4, 2019 · 3 comments
Closed

WebTestClient cannot block when receive infinity stream of SSE #24131

Slava96 opened this issue Dec 4, 2019 · 3 comments

Comments

@Slava96
Copy link

Slava96 commented Dec 4, 2019

Affects: 5.1.5.RELEASE


I try to receive infinity Flux of server sent events represented by strings.

On my test - WebTestClient always throw IllegalStateException, because on the 'exchange' method it uses block with timeout.

Controller code:

private final DirectProcessor<Signal> sseProcessor;

@GetMapping(value = "/signals", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<String> sendSignals() {
    return sseProcessor.publishOn(Schedulers.parallel())
            .doOnNext(signal -> signal.setSent(ZonedDateTime.now()))
            .map(writeSignalAsString())
            .filter(Objects::nonNull);
}

Model:

@Data
@NoArgsConstructor
public class Signal {
    private String id;
    private Type type;
    private ZonedDateTime initiated;
    private ZonedDateTime sent;
    private ZonedDateTime effective;
    private String clue;
    private Map<String, Object> data = new HashMap<>();

    public enum Type {
        TECH_DEDUPLICATION
    }
}

Test code:

        FluxExchangeResult<String> sseFlux = client.get()
                .uri("/v1/signals")
                .exchange()
                .expectStatus().isOk()
                .expectHeader().contentTypeCompatibleWith(TEXT_EVENT_STREAM)
                .returnResult(String.class);

        StepVerifier.create(sseFlux.getResponseBody())
                .assertNext(json -> {
                    String signalInstanceId = JsonPath.parse(json).read("$.data.data.instanceId");
                    assertThat(signalInstanceId, is(duplicateInstanceId));
                })
                .thenCancel().verify();
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 4, 2019
@rstoyanchev
Copy link
Contributor

There was a related recent change #23936 but with or without it I can't reproduce it. Can you try with the latest 5.1.12 (and also 5.2.2) just to be sure? If you still see the problem, please provide a sample.

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Dec 4, 2019
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Dec 11, 2019
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 18, 2019
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

3 participants