Skip to content

Conversation

@flexable777
Copy link
Contributor

No description provided.

@flexable777 flexable777 requested a review from Copilot September 15, 2025 08:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces timeout configuration for WebClient instances to improve reliability and prevent hanging requests. The implementation adds connection, read, write, and response timeouts to HTTP clients.

  • Adds comprehensive timeout configuration with 100-second read/write/response timeouts and 5-second connection timeout
  • Creates a custom HttpClient bean with Netty-based timeout handlers
  • Provides a configured WebClient.Builder bean that uses the timeout-enabled HttpClient

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +17 to +19
@Bean
fun reactorNettyHttpClient(): HttpClient {
val timeoutInSeconds = 100L
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout value of 100 seconds is hardcoded as a magic number. Consider moving this to application properties or a constant with a descriptive name to make it configurable and more maintainable.

Suggested change
@Bean
fun reactorNettyHttpClient(): HttpClient {
val timeoutInSeconds = 100L
/**
* Timeout in seconds for WebClient connections.
* Configurable via 'webclient.timeout.seconds' in application.properties.
*/
@org.springframework.beans.factory.annotation.Value("\${webclient.timeout.seconds:100}")
private val timeoutInSeconds: Long = 100L
@Bean
fun reactorNettyHttpClient(): HttpClient {

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +21
@Bean
fun reactorNettyHttpClient(): HttpClient {
val timeoutInSeconds = 100L
return HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5_000)
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection timeout of 5000 milliseconds is hardcoded as a magic number. Consider extracting this to a constant or configuration property for better maintainability.

Suggested change
@Bean
fun reactorNettyHttpClient(): HttpClient {
val timeoutInSeconds = 100L
return HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5_000)
companion object {
private const val CONNECT_TIMEOUT_MILLIS = 5_000
}
@Bean
fun reactorNettyHttpClient(): HttpClient {
val timeoutInSeconds = 100L
return HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MILLIS)

Copilot uses AI. Check for mistakes.
@flexable777 flexable777 merged commit 7abff0e into main Sep 15, 2025
4 checks passed
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

Successfully merging this pull request may close these issues.

3 participants