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

Dependency management brings an invalid combination of HttpCore5 and HttpClient5 #43113

Closed
donguseo opened this issue Nov 8, 2024 · 12 comments
Closed
Assignees
Labels
for: external-project For an external project and not something we can fix

Comments

@donguseo
Copy link

donguseo commented Nov 8, 2024

I use spring boot 3.3.3.
There is a dependency problem in spring boot 3.3.3.

image

And I think #41374 update may casue this problem.

import org.apache.hc.client5.http.classic.HttpClient
import org.apache.hc.client5.http.config.ConnectionConfig
import org.apache.hc.client5.http.config.RequestConfig
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager
import org.apache.hc.core5.util.Timeout

class HttpClient5ClientFactory {

  companion object {
    fun createHttpClient5Client(): HttpClient {
      val connectionManager = PoolingHttpClientConnectionManager()
      connectionManager.defaultMaxPerRoute = 100
      connectionManager.maxTotal = 100
      connectionManager.setDefaultConnectionConfig(
        ConnectionConfig.custom()
          .setConnectTimeout(Timeout.ofSeconds(1))
          .build()
      )
      val requestConfig = RequestConfig.custom()
        .setResponseTimeout(Timeout.ofSeconds(5))
        .build()

      val httpClientBuilder = HttpClientBuilder.create()
        .useSystemProperties()
        .setConnectionManager(connectionManager)
        .setDefaultRequestConfig(requestConfig)

      val httpClient = httpClientBuilder.build()
      return httpClient
    }
  }
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 8, 2024
@donguseo donguseo changed the title bug: httpcore5 version problem bug: httpcore5 dependency version problem Nov 8, 2024
@bclozel
Copy link
Member

bclozel commented Nov 8, 2024

It looks like a duplicate of spring-projects/spring-framework#33806

Can you try with Framework SNAPSHOTs and report back?

@bclozel bclozel transferred this issue from spring-projects/spring-boot Nov 8, 2024
@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Nov 8, 2024
@donguseo
Copy link
Author

donguseo commented Nov 8, 2024

This doesn't seem to be the same issue. Apache HttpClient 5.3.1 is built with HttpCore5 version 5.2.4. However, in the Gradle file with dependency information on the Spring Boot 3.3.x branch, it specifies version 5.2.5. Although the build succeeds without issues, it's stressful to keep seeing those red underlines in IntelliJ while working. Please compare and verify the versions in the two links below.

https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5/5.3.1
https://github.com/spring-projects/spring-boot/blob/3.3.x/spring-boot-project/spring-boot-dependencies/build.gradle

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 8, 2024
@bclozel
Copy link
Member

bclozel commented Nov 8, 2024

Thanks for your feedback. I'm still not sure I understand this case.
I don't think Spring Boot is bringing multiple or conflicting org.apache.httpcomponents.core5:httpcore5 versions in the classpath. Can you check your application dependency management and report back? Where are the multiple/conflicting versions coming from?

Thanks

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 8, 2024
@donguseo
Copy link
Author

donguseo commented Nov 8, 2024

I just created a sample project and uploaded it to my GitHub repository. Please download it from the link below and check it out.
https://github.com/donguseo/httpcore-dependency

When you open the project in IntelliJ and open the HttpClient5ClientFactory.kt file, you should definitely see the red underlines. You'll also see the httpcore5 version listed as 5.2.5 in the dependencies.

Then, open the build.gradle.kts file and comment out all Spring-related plugins. Rebuild with Gradle, and you’ll notice that the red underlines are gone, and the httpcore5 version has reverted to 5.2.4.

It seems that version 5.2.5 had some changes related to the minimum and maximum JDK versions, which might be causing this issue. I don't have the time to analyze it further. :(

Sorry I couldn't be of more help.
This is probably all I can do for now.
I hope that in the next or subsequent version, this issue will be resolved.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 8, 2024
@donguseo donguseo closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
@bclozel
Copy link
Member

bclozel commented Nov 8, 2024

@donguseo why is this closed?

@donguseo
Copy link
Author

donguseo commented Nov 9, 2024

@donguseo why is this closed?

I considered it a Spring Boot issue, but it was transferred to the Spring Framework, and after that, I received no further feedback on the problem I raised.

I closed the issue because it seemed you weren't taking it seriously. I don't intend to raise this issue again. The quickest solution would be for me to simply use Spring Boot 3.3.1, so it's not a major problem for me. Alternatively, I could resolve it by setting up a separate module for the part that uses Apache HTTP Core and adjusting dependencies accordingly. Even if there’s a red line, it still builds fine, so it’s not critical—just inconvenient.

If you consider my inconvenience a significant issue, I’d appreciate it if you could address it; otherwise, please feel free to disregard it.

@bclozel
Copy link
Member

bclozel commented Nov 9, 2024

We'll have a look. 19 hours is a very short amount of time to consider an issue as disregarded. I will move back this issue to Spring Boot if it turns out to be a bug there.

@bclozel bclozel reopened this Nov 9, 2024
@donguseo
Copy link
Author

donguseo commented Nov 9, 2024

I was too hasty.
Thank you.

@snicoll snicoll changed the title bug: httpcore5 dependency version problem Dependency management for HttpClient5 is incomplete Nov 10, 2024
@snicoll snicoll transferred this issue from spring-projects/spring-framework Nov 10, 2024
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Nov 10, 2024
@snicoll snicoll added this to the 3.2.12 milestone Nov 10, 2024
@snicoll snicoll self-assigned this Nov 10, 2024
@snicoll snicoll added status: waiting-for-triage An issue we've not yet triaged and removed type: bug A general bug labels Nov 10, 2024
@snicoll snicoll removed this from the 3.2.12 milestone Nov 10, 2024
@snicoll snicoll changed the title Dependency management for HttpClient5 is incomplete Dependency management brings an invalid combination of HttpCore5 and HttpClient5 Nov 10, 2024
@snicoll
Copy link
Member

snicoll commented Nov 11, 2024

Thanks for the sample. Looking at what makes it work based on your description, force downgrading HttpCore5 to 5.2.4, makes the error go away. I've added this to your build:

extra["httpcore5.version"] = "5.2.4"

However, I am not sure what the error comes from. Yes the IDE shows an error for me as well but compilation works. Looking at the changelog between 5.2.4 and 5.2.5 I don't see a change that would lead to this problem. At this point, it looks like an error in the IDE.

@donguseo can you make the sample actually fail outside of the IDE? Something like compilation that does not work or an error at runtime?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 11, 2024
@snicoll
Copy link
Member

snicoll commented Nov 11, 2024

The IDE does not show an error for the same code written in Java.

@sdeleuze does that ring any bell?

@donguseo
Copy link
Author

@snicoll
Thank you. Applying it as you described removed the error I mentioned. It seems this resolves the issue I was facing.

Outside of the IDE, there were no problems. The code compiled well, and the functionality worked as expected. Since it’s still in development, I haven't seen any issues in the production environment.

I also checked the changes in httpcore5’s code, and nothing stood out as a significant problem. If you find out why this issue occurred, I’d appreciate any additional comments.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 11, 2024
@snicoll
Copy link
Member

snicoll commented Nov 12, 2024

@donguseo alright, thanks for confirming. Please report this issue to https://youtrack.jetbrains.com/issues. I am going to close this one but feel free to add a link to the issue you've created so that we can follow along.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
@snicoll snicoll added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

4 participants