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

ServerHttpRequest getURI doesn't return the port the application is running on [SPR-15084] #19650

spring-projects-issues opened this issue Jan 3, 2017 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Jan 3, 2017

Abhijit Sarkar opened SPR-15084 and commented

Brain dead simple application:

public class DemoApplication {
    public static void main(String[] args) {, args);

    public static class DemoController {
        public String getUri(ServerHttpRequest request) {
            return request.getURI().toString();


        webEnvironment = RANDOM_PORT
public class DemoApplicationTest {
    private int port;

    private WebClient webClient = WebClient.create(new ReactorClientHttpConnector());

    public void testGetUri() {
        ClientRequest<Void> request = ClientRequest.GET("http://localhost:" + port)

        URI uri =
                .then(response -> response.bodyToMono(String.class))

                .as("Application port: %d, returned port: %d.", port, uri.getPort())


org.junit.ComparisonFailure: [Application port: 14645, returned port: 55802.] 
Expected :14645
Actual   :55802

I've attached the Gradle project.

Affects: 5.0 M4


Referenced from: commits 5cac619

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 14, 2017

wufengbin commented

mabye it's due to your enverment。it calling other process when running your programs

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

Successfully merging a pull request may close this issue.

None yet
2 participants