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

CompletableFuture endpoint with a redirect response returns a 200 #10917

Closed
timyates opened this issue Jun 17, 2024 · 0 comments · Fixed by #10953
Closed

CompletableFuture endpoint with a redirect response returns a 200 #10917

timyates opened this issue Jun 17, 2024 · 0 comments · Fixed by #10953
Assignees
Labels
type: bug Something isn't working

Comments

@timyates
Copy link
Contributor

timyates commented Jun 17, 2024

Expected Behavior

Prior to Micronaut 4, the following returned a 307 response

    MutableHttpResponse createResponse() {
        final override = Map.of(
                'Location', 'http://foo.com',
                'Content-Length', '0',
                'Connection', 'close' )
        return HttpResponse
                .status(HttpStatus.valueOf(307))
                .headers(toMutableHeaders(override))
    }

    @Get("/redirect/fail")
    CompletableFuture<MutableHttpResponse> redirectFail() {
        CompletableFuture.completedFuture(createResponse())
    }

Actual Behaviour

Instead of the expected 307 response, we get a 200 response.

If we add a body to the response by changing the above example to the following, we get 307 as expected

        return HttpResponse
                .status(HttpStatus.valueOf(307))
                .body('')
                .headers(toMutableHeaders(override))

I suspect the issue is here as supplying a body to the response object makes it return the correct status code.

I guess any custom headers are also currently being dropped 🤔

The reproducer is in Groovy, but I don't think it's a Groovy issue 🤔

Steps To Reproduce

Clone https://github.com/munishchouhan/temporaryredirectproblem
Run the tests

Environment Information

No response

Example Application

https://github.com/munishchouhan/temporaryredirectproblem

Version

4.5.0

@timyates timyates added the type: bug Something isn't working label Jun 17, 2024
@graemerocher graemerocher moved this to Todo in 4.5.1 Release Jun 18, 2024
yawkat added a commit that referenced this issue Jul 5, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in 4.5.1 Release Jul 6, 2024
yawkat added a commit that referenced this issue Jul 17, 2024
* fix(deps): update netty monorepo to v4.1.111.final (#10905)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Ensuring the deserialization has access to the ServerRequestContext (#10904)

* Fixes #10665 Ensuring the deserialization has access to the ServerRequestContext

* Adding a test to ensure that large request payloads still have access to the ServerRequestContext on deserialization.

* Map of beans should always use bean definition to extract the name (#10908)

* Improve the ControllerConstraintHandlerTest to accept more HttpRequest body types (#10909)

* Add Kotlin+KSP+Jackson nullable tests (#10927)

The test is reproducing Jackson's default behaviour with primitives and a way to change it

micronaut-projects/micronaut-serialization#880

* Update common files (#10923)

* Revert "Improve the ControllerConstraintHandlerTest to accept more HttpReques…" (#10922)

This reverts commit 3744f17.

* chore(deps): update plugin io.micronaut.build.shared.settings to v6.7.1 (#10770)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency io.github.classgraph:classgraph to v4.8.174 (#8882)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update vertx to v4.5.8 (#10863)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update groovy monorepo to v4.0.22 (#10939)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency me.champeau.gradle:japicmp-gradle-plugin to v0.4.3 (#10885)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update junit5 monorepo (#10945)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update Micronaut Maven Plugin coordinates (#10946)

[skip ci]

* include all non-accessible methods in reflection data (#10947)

Fixes #10880

* Fix CompletableFuture responses without body (#10953)

Fixes #10917

* fix(deps): update dependency com.fasterxml.jackson.dataformat:jackson-dataformat-yaml to v2.17.2 (#10954)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Merge remote-tracking branch 'origin/4.5.x' into merge_4_5_6

# Conflicts:
#	http-server-netty/src/main/java/io/micronaut/http/server/netty/binders/NettyBodyAnnotationBinder.java
#	inject/src/main/java/io/micronaut/context/DefaultBeanContext.java

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Luís Serralheiro <encavadas@gmail.com>
Co-authored-by: Andriy Dmytruk <80816836+andriy-dmytruk@users.noreply.github.com>
Co-authored-by: micronaut-build <65172877+micronaut-build@users.noreply.github.com>
Co-authored-by: Jonas Konrad <jonas.konrad@oracle.com>
Co-authored-by: Álvaro Sánchez-Mariscal <alvaro.sanchez-mariscal@oracle.com>
Co-authored-by: Graeme Rocher <graeme.rocher@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants