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

DefaultWebClient logs URI without the port number #30519

Closed
zvae opened this issue May 23, 2023 · 0 comments
Closed

DefaultWebClient logs URI without the port number #30519

zvae opened this issue May 23, 2023 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@zvae
Copy link

zvae commented May 23, 2023

Affects: 6.0.9
Call the interface of ResourceService, and the interface response status is 500,
webclient execute this method org.springframework.web.reactive.function.client.DefaultWebClient.DefaultResponseSpec#applyStatusHandlers

in DefaultResponseSpec the uri is : http://127.0.0.1:8012/fileUpload?storageType=permanent

applyStatusHandlers method will call

private static URI getUriToLog(URI uri) {
			if (StringUtils.hasText(uri.getQuery())) {
				try {
					uri = new URI(uri.getScheme(), uri.getHost(), uri.getPath(), null);
				}
				catch (URISyntaxException ex) {
					// ignore
				}
			}
			return uri;
		}

this method return uri is http://127.0.0.1/fileUpload, the code (uri = new URI(uri.getScheme(), uri.getHost(), uri.getPath(), null); )returned uri is missing the port number.

error log is :

Error has been observed at the following site(s):
	*__checkpoint ⇢ 500 INTERNAL_SERVER_ERROR from POST http://127.0.0.1/fileUpload [DefaultWebClient]

the config of webClient:

 HttpClient httpClient = HttpClient.create()
                // 配置超时时间
                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)
                .doOnConnected(conn -> conn
                        .addHandlerLast(new ReadTimeoutHandler(10))
                        .addHandlerLast(new WriteTimeoutHandler(10)));
        // 创建client
        WebClient client = WebClient.builder()
                .clientConnector(new ReactorClientHttpConnector(httpClient))
                .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(20 * 1024 * 1024))
                .baseUrl(host)
                .defaultStatusHandler(HttpStatusCode::isError, clientResponse -> {
                    System.out.println("发生异常了。。。。");
                    return Mono.error(new RuntimeException(
                            "请求异常"+ clientResponse.statusCode().value()));
                })
                .build();

      HttpServiceProxyFactory factory =  HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).blockTimeout(Duration.ofSeconds(30)).build();
  return factory.createClient(ResourceService.class)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 23, 2023
@rstoyanchev rstoyanchev self-assigned this Nov 8, 2023
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 8, 2023
@rstoyanchev rstoyanchev added this to the 6.0.14 milestone Nov 8, 2023
@rstoyanchev rstoyanchev changed the title DefaultWebClient log missing requested port number DefaultWebClient logs URI without the port Nov 8, 2023
@rstoyanchev rstoyanchev changed the title DefaultWebClient logs URI without the port DefaultWebClient logs URI without the port number Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants