- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2k
Fix mutating global RestClient and WebClient builders #3020
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
          
     Closed
      
      
            chemicL
  wants to merge
  1
  commit into
  spring-projects:main
from
chemicL:builders-clone-before-mutation
  
      
      
   
      
    
                
     Closed
            
            Fix mutating global RestClient and WebClient builders #3020
                    chemicL
  wants to merge
  1
  commit into
  spring-projects:main
from
chemicL:builders-clone-before-mutation
  
      
      
   
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Since the builders for HTTP clients are mutable and shared, they should only be configured with globally applicable settings. The current use leaks specific details into other usages and affects newly instantiated clients. This PR applies the clone() method right before mutation happens as it probably is the strategy that avoids multiple unnecessary copies. Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
| The build fails due to an unrelated change (b167f21) in the main branch. | 
    
  tzolov 
      added a commit
      that referenced
      this pull request
    
      May 7, 2025 
    
    
      
  
    
      
    
  
Since the builders for HTTP clients are mutable and shared, they should only be configured with globally applicable settings. The current use leaks specific details into other usages and affects newly instantiated clients. This PR applies the clone() method right before mutation happens as it probably is the strategy that avoids multiple unnecessary copies. feat: improve RestClient and WebClient instantiation and configuration across AI modules - Ensure RestClient.Builder and WebClient.Builder are properly cloned before setting base URLs and headers in Mistral, OpenAI, and Ollama API classes to prevent side effects. - Add WebClientAutoConfiguration to auto-configuration classes for Anthropic and Mistral AI modules. - Update Mistral AI auto-configuration to inject and use WebClient.Builder. - Clean up test and annotation usage (remove unnecessary @nullable, fix test builder usage in AnthropicApiIT). - Improve consistency and reliability of HTTP client configuration across model integrations. Signed-off-by: Dariusz Jędrzejczyk <[email protected]> Signed-off-by: Christian Tzolov <[email protected]> Co-authored-by: Christian Tzolov <[email protected]>
| Rebased, Updated with and merged at 97f90b1 | 
    
  namsoo2 
      pushed a commit
        to namsoo2/spring-ai
      that referenced
      this pull request
    
      Jun 9, 2025 
    
    
      
  
    
      
    
  
…s#3020) Since the builders for HTTP clients are mutable and shared, they should only be configured with globally applicable settings. The current use leaks specific details into other usages and affects newly instantiated clients. This PR applies the clone() method right before mutation happens as it probably is the strategy that avoids multiple unnecessary copies. feat: improve RestClient and WebClient instantiation and configuration across AI modules - Ensure RestClient.Builder and WebClient.Builder are properly cloned before setting base URLs and headers in Mistral, OpenAI, and Ollama API classes to prevent side effects. - Add WebClientAutoConfiguration to auto-configuration classes for Anthropic and Mistral AI modules. - Update Mistral AI auto-configuration to inject and use WebClient.Builder. - Clean up test and annotation usage (remove unnecessary @nullable, fix test builder usage in AnthropicApiIT). - Improve consistency and reliability of HTTP client configuration across model integrations. Signed-off-by: Dariusz Jędrzejczyk <[email protected]> Signed-off-by: Christian Tzolov <[email protected]> Co-authored-by: Christian Tzolov <[email protected]> Signed-off-by: minsoo.nam <[email protected]>
    
  chedim 
      pushed a commit
        to couchbaselabs/spring-ai
      that referenced
      this pull request
    
      Sep 19, 2025 
    
    
      
  
    
      
    
  
…s#3020) Since the builders for HTTP clients are mutable and shared, they should only be configured with globally applicable settings. The current use leaks specific details into other usages and affects newly instantiated clients. This PR applies the clone() method right before mutation happens as it probably is the strategy that avoids multiple unnecessary copies. feat: improve RestClient and WebClient instantiation and configuration across AI modules - Ensure RestClient.Builder and WebClient.Builder are properly cloned before setting base URLs and headers in Mistral, OpenAI, and Ollama API classes to prevent side effects. - Add WebClientAutoConfiguration to auto-configuration classes for Anthropic and Mistral AI modules. - Update Mistral AI auto-configuration to inject and use WebClient.Builder. - Clean up test and annotation usage (remove unnecessary @nullable, fix test builder usage in AnthropicApiIT). - Improve consistency and reliability of HTTP client configuration across model integrations. Signed-off-by: Dariusz Jędrzejczyk <[email protected]> Signed-off-by: Christian Tzolov <[email protected]> Co-authored-by: Christian Tzolov <[email protected]>
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Since the builders for HTTP clients are mutable and shared, they should only be configured with globally applicable settings. The current use leaks specific details into other usages and affects newly instantiated clients. This PR applies the clone() method right before mutation happens as it probably is the strategy that avoids multiple unnecessary copies.